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