[Python-Dev] Status on PEP-431 Timezones

Tres Seaver tseaver at palladion.com
Tue Jul 28 14:06:03 CEST 2015


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 07/27/2015 09:36 PM, Tim Peters wrote:
> So what do _you_ do with datetime arithmetic, Tres?  Do you do 
> datetime calculations at all, or just store/retrieve values as-is?
> If the former, are you disturbed that adding timedelta(hours=24) to
> an aware datetime object never changes the time components (only the
> day, and possibly also month, and possibly also year)?  If that has 
> disturbed you, did you find a way to accomplish what you wanted 
> instead - or are you still stuck? ;-)

Sample use cases:

- - Embargo a pre-prepared story until 8:00 AM US/Central next Monday.

- - Likewise, but allow it to run for three weeks.

- - Create a recurring event which occurs from 7:00 - 9:00 PM US/Eastern on
  the last Thursday of each month.

- - Issue a bid for a commodity lot N days before its expiration date;
  update that bid (if another bid has occurred) at the same time each
  day until expiration.

- - Mark messages published on a distributed event channel to allow clients
  to sequence them unambiguously.

- - For a given sequence of events:  if no subsequent matching event occurs
  within five calendar days of the last event in the sequence, issue a
  "resolved" event, terminating the sequence.

- - The same, except define the interval using "business days" (including
  applying a user-defined holiday calendar).

- - Measure / bucket widgets produced across multiple production lines by
  quarter / month / day / shift / hour, and generate reports comparing
  results week-over-week, quarter-over-quarter, etc.

In none of those cases involving "days" was the "one day is 24 hours,
exactly" a sufficient approximation, and none of them could tolerate naive
datetimes.  Typically, the application used a "date interval" object (or a
recurrence object) which generated date offsets without assuming that a
"day" was 86400 seconds.


Tres.
- -- 
===================================================================
Tres Seaver          +1 540-429-0999          tseaver at palladion.com
Palladion Software   "Excellence by Design"    http://palladion.com

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)

iQIcBAEBAgAGBQJVt3ArAAoJEPKpaDSJE9HYfCcP/07RNZY6Vp5wfcR8wnv3Zk/Z
3SgaEWPIG7s8ysqUhcxT/E6pMdgrLDwSm681Ceh8SDFKdvmXIgSO4UXdsHz6X9Ja
gffUk1p5m/A1p0GFdcIMN9EHI1Ligtrf/s0gYJ+b0TqiDUW9mpD1xOmQaNK2/eE4
xf3iYSdFgvcqNMlIzQ+AyzP53M9npv78zCqr/LI18mRczMOHENb98jXeWycIMHyV
TbHL/cZ///Uj1IqAmydezj4K0biPwUeMsNeqzzuMbDsiVFdZn+rql9N+V4BuzINZ
ivmvdEIFdBqFoRcJJyoWsuqaR8GX0i/2LTVgj4Xcustj1Wnh2Aq+2yUNi0DQvjxh
Y79QbVPtPyjkzFUh/dZG5hLSAEWxXtbaFsinq1eN+hraBXHAN4sTdUeL1zGV7Pz5
SSQXwe2cabqALzjbpSiLN8gZ3s7DbcVn4uDLsS3L7iyoC5Y51puZut6ui+TmdbgK
fG2zvkRNayOyiRa1vymNZsjiM9XYrNABVhuVdM+xgqCe62q+bcUKKVKRIZY1JWq4
Fh0hy9MVPeT51oFuaIAPQJfPKleSLf8xElHZ9M0Gm4PbJDvmr04AjZ7MHWicXsqR
pbhlbfIDO8c2Pt7JfjLPGY/0UZi0ZVeJV8bD5EaM3xcn80DLKW9UL+8Yg4h9br59
RURP7/N6S66jAEHfcUFo
=3LBp
-----END PGP SIGNATURE-----



More information about the Python-Dev mailing list