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 minutes

Re: timedelta problem

2014-08-15 Thread Cameron Simpson
On 15Aug2014 13:59, Chris Angelico ros...@gmail.com wrote: On Fri, Aug 15, 2014 at 1:51 PM, Denis McMahon denismfmcma...@gmail.com 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

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 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 (and

Re: timedelta problem

2014-08-15 Thread Ian Kelly
On Fri, Aug 15, 2014 at 1:39 AM, Denis McMahon denismfmcma...@gmail.com 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

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 denismfmcma...@gmail.com 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,

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 denismfmcma...@gmail.com 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

Re: timedelta problem

2014-08-15 Thread Ian Kelly
On Fri, Aug 15, 2014 at 11:43 AM, Denis McMahon denismfmcma...@gmail.com wrote: On Fri, 15 Aug 2014 09:23:02 -0600, Ian Kelly wrote: On Fri, Aug 15, 2014 at 1:39 AM, Denis McMahon denismfmcma...@gmail.com wrote: On Fri, 15 Aug 2014 10:24:47 +0800, luofeiyu wrote: On further inspection, it

timedelta problem

2014-08-14 Thread luofeiyu
In the python doc , https://docs.python.org/3.4/library/datetime.html A timedelta https://docs.python.org/3.4/library/datetime.html#datetime.timedelta object represents a duration, the difference between two dates or times. /class /datetime.timedelta(/days=0/, /seconds=0/, /microseconds=0/,

Re: timedelta problem

2014-08-14 Thread Ben Finney
luofeiyu elearn2...@gmail.com 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)))

Re: timedelta problem

2014-08-14 Thread Ian Kelly
On Thu, Aug 14, 2014 at 8:24 PM, luofeiyu elearn2...@gmail.com 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,

Re: timedelta problem

2014-08-14 Thread Ian Kelly
On Thu, Aug 14, 2014 at 9:37 PM, Ian Kelly ian.g.ke...@gmail.com wrote: On Thu, Aug 14, 2014 at 8:24 PM, luofeiyu elearn2...@gmail.com 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

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, %d %b

Re: timedelta problem

2014-08-14 Thread Chris Angelico
On Fri, Aug 15, 2014 at 1:51 PM, Denis McMahon denismfmcma...@gmail.com 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?

Re: timedelta problem

2014-08-14 Thread Ian Kelly
On Thu, Aug 14, 2014 at 9:51 PM, Denis McMahon denismfmcma...@gmail.com 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