Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#26571 closed Cleanup/optimization (fixed)

Documentation about usage of fromtimestamp (wrt timezones) is confusing

Reported by: Torsten Bronger Owned by: nobody
Component: Documentation Version: 1.9
Severity: Normal Keywords:
Cc: bronger@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

On <https://docs.djangoproject.com/en/1.9/topics/i18n/timezones/#default-current-time-zone>, it says:

For instance, use utcfromtimestamp() instead of fromtimestamp()
– and don’t forget to set tzinfo to utc.

But isn't the straightfoward way for getting a timezone-aware UTC object

fromtimestamp(time.time(), utc)

?

Change History (5)

comment:1 by Aymeric Augustin, 8 years ago

Triage Stage: UnreviewedAccepted

Indeed, I wasn't aware of the optional second parameter to fromtimestamp when I wrote this note.

comment:2 by Tim Graham, 8 years ago

Has patch: set

PR -- is it correct?

comment:3 by Torsten Bronger, 8 years ago

LGTM.

comment:4 by GitHub <noreply@…>, 8 years ago

Resolution: fixed
Status: newclosed

In d60386d:

Fixed #26571 -- Corrected recommendation for converting timestamps to tz-aware datetimes.

comment:5 by Tim Graham <timograham@…>, 8 years ago

In 33783a9:

[1.10.x] Fixed #26571 -- Corrected recommendation for converting timestamps to tz-aware datetimes.

Backport of d60386d0f5333c7fef4c5906a3358b00cf9de3bf from master

Note: See TracTickets for help on using tickets.
Back to Top