|
3 | 3 | import pickle
|
4 | 4 | import re
|
5 | 5 | import warnings
|
6 |
| -from datetime import date, datetime |
| 6 | +from datetime import datetime |
7 | 7 | from pathlib import Path
|
8 | 8 |
|
9 | 9 | import tagulous
|
@@ -188,7 +188,7 @@ def __init__(self, attrs=None, years=None, *, required=True):
|
188 | 188 | if years:
|
189 | 189 | self.years = years
|
190 | 190 | else:
|
191 |
| - this_year = date.today().year |
| 191 | + this_year = timezone.now().year |
192 | 192 | self.years = list(range(this_year - 10, this_year + 1))
|
193 | 193 |
|
194 | 194 | def render(self, name, value, attrs=None, renderer=None):
|
@@ -642,7 +642,7 @@ def clean_tags(self):
|
642 | 642 | # date can only be today or in the past, not the future
|
643 | 643 | def clean_scan_date(self):
|
644 | 644 | date = self.cleaned_data.get("scan_date", None)
|
645 |
| - if date and date.date() > datetime.today().date(): |
| 645 | + if date and date.date() > timezone.now().date(): |
646 | 646 | msg = "The date cannot be in the future!"
|
647 | 647 | raise forms.ValidationError(msg)
|
648 | 648 | return date
|
@@ -3582,7 +3582,7 @@ class Meta:
|
3582 | 3582 | def clean_expiration(self):
|
3583 | 3583 | expiration = self.cleaned_data.get("expiration", None)
|
3584 | 3584 | if expiration:
|
3585 |
| - today = datetime.today().date() |
| 3585 | + today = timezone.now().date() |
3586 | 3586 | if expiration < today:
|
3587 | 3587 | msg = "The expiration cannot be in the past"
|
3588 | 3588 | raise forms.ValidationError(msg)
|
|
0 commit comments