Changes between Initial Version and Version 1 of Ticket #17992, comment 4


Ignore:
Timestamp:
Mar 28, 2012, 4:57:29 AM (12 years ago)
Author:
Aymeric Augustin

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #17992, comment 4

    initial v1  
    11Anssi suggests that `localtime` should use the current time zone, which can be explicitly changed if necessary.
    22
    3 This would resolve the most common use case, and mirror the behavior of the template engine.
     3{{{
     4datetime_in_current_tz = localtime(datetime_in_any_tz)
     5
     6with timezone.override(get_default_timezone()):
     7    datetime_in_default_tz = localtime(datetime_in_any_tz)
     8
     9with timezone.override(other_tz):
     10    datetime_in_other_tz = localtime(datetime_in_any_tz)
     11}}}
     12
     13The alternative is to add an optional argument:
     14
     15
     16{{{
     17datetime_in_current_tz = localtime(datetime_in_any_tz)
     18
     19datetime_in_default_tz = localtime(datetime_in_any_tz, get_default_timezone())
     20
     21datetime_in_other_tz = localtime(datetime_in_any_tz, other_tz)
     22}}}
     23
     24I have a slight preference for the second version, mostly because it is shorter.
     25
     26No better name than `localtime` came up during the IRC discussion.
Back to Top