Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #76355

Re: timedelta problem

From Denis McMahon <denismfmcmahon@gmail.com>
Newsgroups comp.lang.python
Subject Re: timedelta problem
Date 2014-08-15 07:39 +0000
Organization A noiseless patient Spider
Message-ID <lskdfb$6bg$1@dont-email.me> (permalink)
References <mailman.13018.1408069502.18130.python-list@python.org>

Show all headers | View raw


On Fri, 15 Aug 2014 10:24:47 +0800, luofeiyu wrote:

On further inspection, it seems that strptime() in 2.7 doesn't handle %z 
at all. In 3.2, it ignores the value it gets, because there's no 
practical way to select the "right" tz string from the offset.

For example, a dictionary of offset minutes to tzstrings looks something 
like this:

{
-720: ['BIT'], 
-660: ['NUT', 'SST'], 
-600: ['CKT', 'HAST', 'HST', 'TAHT'], 
-570: ['MART', 'MIT'], 
-540: ['AKST', 'GAMT', 'GIT', 'HADT'], 
-480: ['AKDT', 'CIST', 'PST'], 
-420: ['MST', 'PDT'], 
-360: ['CST', 'EAST', 'GALT', 'MDT'], 
-300: ['CDT', 'COT', 'CST', 'EASST', 'ECT', 'EST', 'PET'], 
-270: ['VET'], 
-240: ['AMT', 'AST', 'BOT', 'CDT', 'CLT', 'COST', 'ECT', 'EDT', 'FKT', 
'GYT', 'PYT'], 
-210: ['NST', 'NT'], 
-180: ['ADT', 'AMST', 'ART', 'BRT', 'CLST', 'FKST', 'FKST', 'GFT', 'PMST', 
'PYST', 'ROTT', 'SRT', 'UYT'], 
-150: ['NDT'], 
-120: ['FNT', 'GST', 'PMDT', 'UYST'], 
-60: ['AZOST', 'CVT', 'EGT'], 
0: ['GMT', 'UCT', 'UTC', 'WET', 'Z', 'EGST'], 
60: ['BST', 'CET', 'DFT', 'IST', 'MET', 'WAT', 'WEDT', 'WEST'], 
120: ['CAT', 'CEDT', 'CEST', 'EET', 'HAEC', 'IST', 'MEST', 'SAST', 
'WAST'], 
180: ['AST', 'EAT', 'EEDT', 'EEST', 'FET', 'IDT', 'IOT', 'SYOT'], 
210: ['IRST'], 
240: ['AMT', 'AZT', 'GET', 'GST', 'MSK', 'MUT', 'RET', 'SAMT', 'SCT', 
'VOLT'], 
270: ['AFT', 'IRDT'], 
300: ['AMST', 'HMT', 'MAWT', 'MVT', 'ORAT', 'PKT', 'TFT', 'TJT', 'TMT', 
'UZT'], 
330: ['IST', 'SLST'], 
345: ['NPT'], 
360: ['BIOT', 'BST', 'BTT', 'KGT', 'VOST', 'YEKT'], 
390: ['CCT', 'MMT', 'MST'], 
420: ['CXT', 'DAVT', 'HOVT', 'ICT', 'KRAT', 'OMST', 'THA', 'WIT'], 
480: ['ACT', 'AWST', 'BDT', 'CHOT', 'CIT', 'CST', 'CT', 'HKT', 'MST', 
'MYT', 'PST', 'SGT', 'SST', 'ULAT', 'WST'], 
525: ['CWST'], 
540: ['AWDT', 'EIT', 'IRKT', 'JST', 'KST', 'TLT'], 
570: ['ACST', 'CST'], 
600: ['AEST', 'CHUT', 'DDUT', 'EST', 'PGT', 'VLAT', 'YAKT'], 
630: ['ACDT', 'CST', 'LHST'], 
660: ['AEDT', 'KOST', 'LHST', 'MIST', 'NCT', 'PONT', 'SAKT', 'SBT', 
'VUT'], 
690: ['NFT'], 
720: ['FJT', 'GILT', 'MAGT', 'MHT', 'NZST', 'PETT', 'TVT', 'WAKT'], 
765: ['CHAST']
780: ['NZDT', 'PHOT', 'TKT', 'TOT'], 
825: ['CHADT'], 
840: ['LINT'], 
}

I've patched my 2.7 to set a tz string of "UTC[+-]nnnn" from the [+-]nnnn 
%z value.

-- 
Denis McMahon, denismfmcmahon@gmail.com

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

timedelta  problem luofeiyu <elearn2014@gmail.com> - 2014-08-15 10:24 +0800
  Re: timedelta  problem Denis McMahon <denismfmcmahon@gmail.com> - 2014-08-15 03:51 +0000
    Re: timedelta problem Chris Angelico <rosuav@gmail.com> - 2014-08-15 13:59 +1000
    Re: timedelta problem Ian Kelly <ian.g.kelly@gmail.com> - 2014-08-14 22:00 -0600
  Re: timedelta  problem Denis McMahon <denismfmcmahon@gmail.com> - 2014-08-15 07:39 +0000
    Re: timedelta  problem Denis McMahon <denismfmcmahon@gmail.com> - 2014-08-15 08:44 +0000
    Re: timedelta problem Ian Kelly <ian.g.kelly@gmail.com> - 2014-08-15 09:23 -0600
      Re: timedelta problem Denis McMahon <denismfmcmahon@gmail.com> - 2014-08-15 17:43 +0000
        Re: timedelta problem Ian Kelly <ian.g.kelly@gmail.com> - 2014-08-15 12:05 -0600
    Re: timedelta problem Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-08-15 17:29 +0100
  Re: timedelta  problem Denis McMahon <denismfmcmahon@gmail.com> - 2014-08-15 09:36 +0000

csiph-web