This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author belopolsky
Recipients ajaksu2, belopolsky, brett.cannon, doerwalter, eric.araujo, ggenellina, kawai, mark.dickinson, pitrou, rafe, vstinner
Date 2010-06-03.22:58:05
SpamBayes Score 1.1262986e-07
Marked as misclassified No
Message-id <1275605888.22.0.454304516486.issue5094@psf.upfronthosting.co.za>
In-reply-to
Content
I am having second thoughts about dst indicator.  I wrote:
"""
2. Do we want to add a dst indicator and altname attributes? I would say: no. I would rather treat DST as a different fixed offset timezone.
"""

and Brett responded: 
"""
2. Keep the class dead-simple. The primary motivator is to support UTC, maybe the %z directive for strptime. Otherwise everything else should be left out of the stdlib and let third-parties manage it as they will be the ones that need to manage the bazillion timezone instances they need. We don't need to dictate an interface to them.
"""

Now note, that with fixed offset timezone class, it is possible to produce aware local times as follows:

from datetime import datetime, timezone, timedelta
import time
EPOCH = datetime(1970, 1, 1)
def localtime(utctime=None):
    if utctime is None:
        tm = time.localtime()
    else:
        seconds = (utctime - EPOCH).total_seconds()
        tm = time.localtime(seconds)

    tz = (timezone(timedelta(seconds=-time.altzone), time.tzname[1])
          if tm.tm_isdst else
          timezone(timedelta(seconds=-time.timezone), time.tzname[0]))
    return datetime(*tm[:6], tzinfo=tz)

(see also attached localtime.py)

The problem with the above implementation is that t.timetuple().tm_isdst will always be 0 if t is produced by localtime().

I don't think adding fixed dst offset is much of complication.  We already need to override the tzinfo.dst method and if we only allow timedeltas as offset and dst arguments to constructor, the constructor code will be extremely simple.
History
Date User Action Args
2010-06-03 22:58:08belopolskysetrecipients: + belopolsky, doerwalter, brett.cannon, mark.dickinson, ggenellina, pitrou, vstinner, ajaksu2, kawai, eric.araujo, rafe
2010-06-03 22:58:08belopolskysetmessageid: <1275605888.22.0.454304516486.issue5094@psf.upfronthosting.co.za>
2010-06-03 22:58:06belopolskylinkissue5094 messages
2010-06-03 22:58:06belopolskycreate