diff options
| author | Nick Pope <nick@nickpope.me.uk> | 2021-05-07 10:42:59 +0100 |
|---|---|---|
| committer | Carlton Gibson <carlton.gibson@noumenal.es> | 2021-05-12 11:08:41 +0200 |
| commit | d06c5b358149c02a62da8a5469264d05f29ac659 (patch) | |
| tree | 2ca0d6884062980dea5e8085af0868f9d9b5a266 /django/http | |
| parent | 69ffb1acf38bd34f76707468bb592eb4b164e2da (diff) | |
Fixed #32366 -- Updated datetime module usage to recommended approach.
- Replaced datetime.utcnow() with datetime.now().
- Replaced datetime.utcfromtimestamp() with datetime.fromtimestamp().
- Replaced datetime.utctimetuple() with datetime.timetuple().
- Replaced calendar.timegm() and datetime.utctimetuple() with datetime.timestamp().
Diffstat (limited to 'django/http')
| -rw-r--r-- | django/http/response.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/django/http/response.py b/django/http/response.py index f1f0a1ed43..99f0020335 100644 --- a/django/http/response.py +++ b/django/http/response.py @@ -203,9 +203,9 @@ class HttpResponseBase: self.cookies[key] = value if expires is not None: if isinstance(expires, datetime.datetime): - if timezone.is_aware(expires): - expires = timezone.make_naive(expires, timezone.utc) - delta = expires - expires.utcnow() + if timezone.is_naive(expires): + expires = timezone.make_aware(expires, timezone.utc) + delta = expires - datetime.datetime.now(tz=timezone.utc) # Add one second so the date matches exactly (a fraction of # time gets lost between converting to a timedelta and # then the date string). |
