# 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('America/Los_Angeles')
>>> denver = timezone('America/Denver')
>>> chicago = timezone('America/Chicago')
>>> detroit = timezone('America/Detroit')

>>> datetime.now().replace(tzinfo=la).utcoffset().total_seconds() / 3600
-8.0

>>> datetime.now().replace(tzinfo=denver).utcoffset().total_seconds() / 3600
-7.0

>>> datetime.now().replace(tzinfo=chicago).utcoffset().total_seconds() / 3600
-6.0

>>> datetime.now().replace(tzinfo=detroit).utcoffset().total_seconds() / 3600
-5.533333333333333

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('US/Eastern')
>>> central = timezone('US/Central')
>>> mountain = timezone('US/Mountain')
>>> now = datetime.now()

>>> now.replace(tzinfo=eastern).utcoffset().total_seconds() / 3600
-5.0
>>> now.replace(tzinfo=central).utcoffset().total_seconds() / 3600
-6.0
>>> now.replace(tzinfo=mountain).utcoffset().total_seconds() / 3600
-7.0

>>> now.replace(tzinfo=eastern).strftime('%H:%M:%S %z')
'16:15:53 -0500'

>>> now.replace(tzinfo=eastern).astimezone(central).strftime('%H:%M:%S %z')
'16:15:53 -0500'

>>> now.replace(tzinfo=eastern).astimezone(mountain).strftime('%H:%M:%S %z')
'15:15:53 -0600'

>>> utc = timezone('UTC')
>>> nowutc = datetime.utcnow().replace(tzinfo=utc)

>>> nowutc.astimezone(eastern).strftime('%H:%M:%S %z')
'16:24:14 -0400'
>>> nowutc.astimezone(central).strftime('%H:%M:%S %z')
'15:24:14 -0500'
>>> nowutc.astimezone(mountain).strftime('%H:%M:%S %z')
'14:24:14 -0600'

## Question information

Language:
English Edit question
Status:
For:
pytz Edit question
Assignee:
No assignee Edit question
Last query:

This question was originally filed as bug #1232545.

 Revision history for this message Dustin Oprea (myselfasunder) said on 2013-09-28: #1

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('America/Los_Angeles')
>>> denver = timezone('America/Denver')
>>> chicago = timezone('America/Chicago')
>>> detroit = timezone('America/Detroit')

>>> datetime.now().replace(tzinfo=la).utcoffset().total_seconds() / 3600
-8.0

>>> datetime.now().replace(tzinfo=denver).utcoffset().total_seconds() / 3600
-7.0

>>> datetime.now().replace(tzinfo=chicago).utcoffset().total_seconds() / 3600
-6.0

>>> datetime.now().replace(tzinfo=detroit).utcoffset().total_seconds() / 3600
-5.533333333333333

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('US/Eastern')
>>> central = timezone('US/Central')
>>> mountain = timezone('US/Mountain')
>>> now = datetime.now()

>>> now.replace(tzinfo=eastern).utcoffset().total_seconds() / 3600
-5.0
>>> now.replace(tzinfo=central).utcoffset().total_seconds() / 3600
-6.0
>>> now.replace(tzinfo=mountain).utcoffset().total_seconds() / 3600
-7.0

>>> now.replace(tzinfo=eastern).strftime('%H:%M:%S %z')
'16:15:53 -0500'

>>> now.replace(tzinfo=eastern).astimezone(central).strftime('%H:%M:%S %z')
'16:15:53 -0500'

>>> now.replace(tzinfo=eastern).astimezone(mountain).strftime('%H:%M:%S %z')
'15:15:53 -0600'

>>> utc = timezone('UTC')
>>> nowutc = datetime.utcnow().replace(tzinfo=utc)

>>> nowutc.astimezone(eastern).strftime('%H:%M:%S %z')
'16:24:14 -0400'
>>> nowutc.astimezone(central).strftime('%H:%M:%S %z')
'15:24:14 -0500'
>>> nowutc.astimezone(mountain).strftime('%H:%M:%S %z')
'14:24:14 -0600'

 Revision history for this message Stuart Bishop (stub) said on 2013-10-01: #2