Re: timedelta problem

2014-08-15 Thread Ian Kelly
On Fri, Aug 15, 2014 at 11:43 AM, Denis McMahon wrote: > On Fri, 15 Aug 2014 09:23:02 -0600, Ian Kelly wrote: > >> On Fri, Aug 15, 2014 at 1:39 AM, Denis McMahon >> wrote: >>> On Fri, 15 Aug 2014 10:24:47 +0800, luofeiyu wrote: >>> >>> On further inspection, it seems that strptime() in 2.7 doesn'

Re: timedelta problem

2014-08-15 Thread Denis McMahon
On Fri, 15 Aug 2014 09:23:02 -0600, Ian Kelly wrote: > On Fri, Aug 15, 2014 at 1:39 AM, Denis McMahon > wrote: >> 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, bec

Re: timedelta problem

2014-08-15 Thread Mark Lawrence
On 15/08/2014 16:23, Ian Kelly wrote: On Fri, Aug 15, 2014 at 1:39 AM, Denis McMahon wrote: 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 wa

Re: timedelta problem

2014-08-15 Thread Ian Kelly
On Fri, Aug 15, 2014 at 1:39 AM, Denis McMahon wrote: > 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 strin

Re: timedelta problem

2014-08-15 Thread Denis McMahon
On Fri, 15 Aug 2014 10:24:47 +0800, luofeiyu wrote: > problem : > > t1 is GMT time 2014 00:36:46 t2 is GMT time 2014 14:36:46 > > datetime.datetime.strptime do not give me the right answer. As far as I can tell from running the following, it all seems to work as expected in python 3.2 (

Re: timedelta problem

2014-08-15 Thread Denis McMahon
On Fri, 15 Aug 2014 07:39:23 +, Denis McMahon wrote: > I've patched my 2.7 to set a tz string of "UTC[+-]" from the > [+-] %z value. ... but that doesn't do much, because time.struct_time in 2.7 doesn't recognise anything that strptime passes in as a tz at all, as it expects the dst

Re: timedelta problem

2014-08-15 Thread Cameron Simpson
On 15Aug2014 13:59, Chris Angelico wrote: On Fri, Aug 15, 2014 at 1:51 PM, Denis McMahon wrote: AttributeError: 'module' object has no attribute 'timezone' Both fail as you describe in 2.7, but in 3.4/3.5ish (my 'python3' is a bit of a mess, but it's something between those two I think), bot

Re: timedelta problem

2014-08-15 Thread Denis McMahon
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 minute

Re: timedelta problem

2014-08-14 Thread Ian Kelly
On Thu, Aug 14, 2014 at 9:51 PM, Denis McMahon wrote: > > On Fri, 15 Aug 2014 10:24:47 +0800, luofeiyu wrote: > > > import datetime > > t1='Sat, 09 Aug 2014 07:36:46 -0700' > > t2='Sat, 09 Aug 2014 07:36:46 +0700' > > datetime.datetime.strptime(t1,"%a, %d %b %Y %H:%M:%S %z") > > Are you sure? When

Re: timedelta problem

2014-08-14 Thread Chris Angelico
On Fri, Aug 15, 2014 at 1:51 PM, Denis McMahon wrote: > On Fri, 15 Aug 2014 10:24:47 +0800, luofeiyu wrote: > >> import datetime >> t1='Sat, 09 Aug 2014 07:36:46 -0700' >> t2='Sat, 09 Aug 2014 07:36:46 +0700' >> datetime.datetime.strptime(t1,"%a, %d %b %Y %H:%M:%S %z") > > Are you sure? When I try

Re: timedelta problem

2014-08-14 Thread Denis McMahon
On Fri, 15 Aug 2014 10:24:47 +0800, luofeiyu wrote: > import datetime > t1='Sat, 09 Aug 2014 07:36:46 -0700' > t2='Sat, 09 Aug 2014 07:36:46 +0700' > datetime.datetime.strptime(t1,"%a, %d %b %Y %H:%M:%S %z") Are you sure? When I try this I get: ValueError: 'z' is a bad directive in format '%a, %

Re: timedelta problem

2014-08-14 Thread Ian Kelly
On Thu, Aug 14, 2014 at 9:37 PM, Ian Kelly wrote: > On Thu, Aug 14, 2014 at 8:24 PM, luofeiyu wrote: > > t1 is GMT time 2014 00:36:46 > > t2 is GMT time 2014 14:36:46 > > You have it backwards. t1 is a later time than t2. > > > datetime.datetime.strptime do not give me the right answer. >

Re: timedelta problem

2014-08-14 Thread Ian Kelly
On Thu, Aug 14, 2014 at 8:24 PM, luofeiyu wrote: > import datetime > t1='Sat, 09 Aug 2014 07:36:46 -0700' > t2='Sat, 09 Aug 2014 07:36:46 +0700' > >>> datetime.datetime.strptime(t1,"%a, %d %b %Y %H:%M:%S %z") > datetime.datetime(2014, 8, 9, 7, 36, 46, tzinfo=datetime.timezone(datetime.timed > elta

Re: timedelta problem

2014-08-14 Thread Ben Finney
luofeiyu writes: > import datetime > t1='Sat, 09 Aug 2014 07:36:46 -0700' > t2='Sat, 09 Aug 2014 07:36:46 +0700' > >>> datetime.datetime.strptime(t1,"%a, %d %b %Y %H:%M:%S %z") > datetime.datetime(2014, 8, 9, 7, 36, 46, > tzinfo=datetime.timezone(datetime.timed > elta(-1, 61200))) > >>> datetime.