Odd behavior and offsets when using now() rather than utcnow()
1) Why do the given offsets not reflect DST (see below)? Mountain, Central, and Eastern
should currently be at -6, -5, -4, respectively.
2) Why does Detroit have the odd offset '-5.53..'? It should be -5, when not DST. EST and
US/Eastern are -5, as expected (though they still don't reflect DST).
>>> from pytz import timezone
>>> from datetime import datetime
>>> la = timezone(
>>> denver = timezone(
>>> chicago = timezone(
>>> detroit = timezone(
>>> datetime.
-8.0
>>> datetime.
-7.0
>>> datetime.
-6.0
>>> datetime.
-5.
3) Why don't I get different times when converting Eastern to Central? It works fine
when I convert from Eastern to Mountain:
>>> eastern = timezone(
>>> central = timezone(
>>> mountain = timezone(
>>> now = datetime.now()
>>> now.replace(
-5.0
>>> now.replace(
-6.0
>>> now.replace(
-7.0
>>> now.replace(
'16:15:53 -0500'
>>> now.replace(
'16:15:53 -0500'
>>> now.replace(
'15:15:53 -0600'
Yet, everything works fine when I start with utcnow() instead of now():
>>> utc = timezone('UTC')
>>> nowutc = datetime.
>>> nowutc.
'16:24:14 -0400'
>>> nowutc.
'15:24:14 -0500'
>>> nowutc.
'14:24:14 -0600'
Question information
- Language:
- English Edit question
- Status:
- Answered
- For:
- pytz Edit question
- Assignee:
- No assignee Edit question
- Last query:
- Last reply:
This question was originally filed as bug #1232545.
Can you help with this problem?
Provide an answer of your own, or ask Dustin Oprea for more information if necessary.