1
0
mirror of https://github.com/django/django.git synced 2025-10-27 15:46:10 +00:00

Fixed #16906 -- Format datetimes with str/unicode instead of strftime where possible: it's faster and it works for all dates.

Also ensured that datetime_safe is used wherever strftime is called on dates/datetimes that may be before 1900.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@16978 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Aymeric Augustin
2011-10-13 19:23:45 +00:00
parent b7845768cb
commit 06d9b82a27
7 changed files with 22 additions and 31 deletions

View File

@@ -52,14 +52,13 @@ class PasswordResetTokenGenerator(object):
# invalid as soon as it is used.
# We limit the hash to 20 chars to keep URL short
key_salt = "django.contrib.auth.tokens.PasswordResetTokenGenerator"
value = unicode(user.id) + \
user.password + user.last_login.strftime('%Y-%m-%d %H:%M:%S') + \
unicode(timestamp)
value = (unicode(user.id) + user.password +
unicode(user.last_login) + unicode(timestamp))
hash = salted_hmac(key_salt, value).hexdigest()[::2]
return "%s-%s" % (ts_b36, hash)
def _num_days(self, dt):
return (dt - date(2001,1,1)).days
return (dt - date(2001, 1, 1)).days
def _today(self):
# Used for mocking in tests