mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-04-05 03:00:15 -04:00
Fix cc date validation error
This check was raising a value error if run on the 31st against an expiration date in a month that only had 30 days. Now we pick the 1st day of the month, which is guaranteed to exist. Also uses the correct timezone.
This commit is contained in:
@@ -1665,14 +1665,14 @@ class ValidCard(Validator):
|
||||
self.set_error(_("dates should be YYYY-MM"), "expirationDate")
|
||||
has_errors = True
|
||||
else:
|
||||
now = datetime.now()
|
||||
now = datetime.now(g.tz)
|
||||
yyyy, mm = expirationDate.split("-")
|
||||
year = int(yyyy)
|
||||
month = int(mm)
|
||||
if month < 1 or month > 12:
|
||||
self.set_error(_("month must be in the range 01..12"), "expirationDate")
|
||||
has_errors = True
|
||||
elif datetime(year, month, now.day) < now:
|
||||
elif datetime(year, month, 1) < datetime(now.year, now.month, 1):
|
||||
self.set_error(_("expiration date must be in the future"), "expirationDate")
|
||||
has_errors = True
|
||||
|
||||
|
||||
Reference in New Issue
Block a user