[Datetime-SIG] naive DateTime, aware DateTime, precise DateTIme

Chris Barker chris.barker at noaa.gov
Fri Jul 31 00:22:16 CEST 2015


On Thu, Jul 30, 2015 at 2:00 PM, Ethan Furman <ethan at stoneleaf.us> wrote:


> It is exactly those grey areas that have caused all the hullabaloo, and
> that's where 24 hours isn't (through no fault of timedelta).


Exactly -- but that's really dangerous, actually, if something works "as
expected" most of the time, people will blindly go about their business
using it, and then get an ugly bug report way down the line (hopefully).

 my thought is to either make an entirely new type, or have a keyword
> argument, with the effect of a datetime that does account for dst switches:
>
> # HYPOTHETICAL CODE, DOES NOT CURRENTLY WORK
> --> my_time = datetime(2015, 3, 7, 13, 30, tzinfo=Pacific, precise=True)
> --> my_time.strftime('%H:%M %z')
> '13:30 -0800'
> --> (my_time + 24 * HOUR).strftime('%H:%M %z')
> '14:30 -0700'  # assuming I did the math right in my head ;)
>
> I must admit, though, I'm not sure how often such a class would be used --
> if the application is important enough to be exact with the durations
> (nuclear power plants, flying planes, etc.) then I would think a time zone
> such as UTC would be used just to avoid any possible confusion around those
> dst switches.
>

There is a hug gap between "needs to be accurate to less than hour" and
 "nuclear power plants, flying planes"

I for one, work all the time with datasets that, yes, SHOULD all be in UTC,
but are often not, and I need to both accept input and return output in
whatever timezone the user has/needs, and arithmetic had better be real,
genuine 24 hours is 24 hours....

In fact, I can certainly see that some use cases call for Period Arithmetic
(which I never need), but I can't image a use case that calls for Duration
Arithmetic but doesn't care about an hour one way or the other!

In practice, all my code does the time-zone conversion on I/O, keeping
everything in naive datetimes internally (or unix tics -- ugg!) But it
would be nice nice to have good, robust time-zone aware datetimes instead

-Chris

-- 

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/datetime-sig/attachments/20150730/e288c2b1/attachment-0001.html>


More information about the Datetime-SIG mailing list