Re: convert time

2011-09-12 Thread nn
On Sep 11, 1:00 am, Steven D'Aprano wrote: > 守株待兔 wrote: > > how can i convert "Dec 11" into  2011-12? > > if my_str == "Dec 11": >     return 1999  # 2011 - 12 > > Does that help? > > But seriously... 2011-12 is not a proper date, so the simplest way is > probably something like this: > > def con

Re: convert time

2011-09-10 Thread Ben Finney
Steven D'Aprano writes: > But seriously... 2011-12 is not a proper date It's valid by ISO 8601. The standard allows any number of parts to be dropped, from least to most significant, in order to have a value with deliberately reduced precision. https://secure.wikimedia.org/wikipedia/en/wiki

Re: convert time

2011-09-10 Thread Steven D'Aprano
守株待兔 wrote: > how can i convert "Dec 11" into 2011-12? if my_str == "Dec 11": return 1999 # 2011 - 12 Does that help? But seriously... 2011-12 is not a proper date, so the simplest way is probably something like this: def convert(date_str): month, short_year = date_str.split()

Re: convert time

2011-09-10 Thread Chris Rebert
2011/9/10 守株待兔 <1248283...@qq.com>: > how can i convert "Dec 11" into  2011-12? Read the fine manuals for the `time` or `datetime` modules. http://docs.python.org/library/datetime.html >>> from datetime import datetime >>> datetime.strptime("Dec 11", "%b %y") datetime.datetime(2011, 12, 1, 0, 0)

Re: convert time to UTC seconds since epoch

2010-07-21 Thread Steve Allen
On Jul 20, 6:57 pm, Chris Rebert wrote: [regarding trust of POSIX vis a vis leap seconds] > I'm not saying they necessarily should, but they're standardized and > the `time` module is based on POSIX/Unix-ish assumptions; not > following POSIX would be inconsistent and problematic. > Breaking stand

Re: convert time to UTC seconds since epoch

2010-07-20 Thread Chris Rebert
On Tue, Jul 20, 2010 at 6:48 PM, Greg Hennessy wrote: > On 2010-07-21, Chris Rebert wrote: >> On Tue, Jul 20, 2010 at 6:31 PM, Greg Hennessy wrote: >>> Given the documentation talks about "double leap seconds" which don't >>> exist, why should this code be trusted? >> >> Because they exist(ed) i

Re: convert time to UTC seconds since epoch

2010-07-20 Thread Greg Hennessy
On 2010-07-21, Chris Rebert wrote: > On Tue, Jul 20, 2010 at 6:31 PM, Greg Hennessy wrote: >> Given the documentation talks about "double leap seconds" which don't >> exist, why should this code be trusted? > > Because they exist(ed) in POSIX. Why should POSIX time calculations involving leap se

Re: convert time to UTC seconds since epoch

2010-07-20 Thread Chris Rebert
On Tue, Jul 20, 2010 at 6:31 PM, Greg Hennessy wrote: > On 2010-07-20, Rami Chowdhury wrote: >> If you have a sufficiently recent version of Python, have you >>considered time.strptime: >>http://docs.python.org/library/time.html#time.strptime ? > > Given the documentation talks about "double leap

Re: convert time to UTC seconds since epoch

2010-07-20 Thread Greg Hennessy
On 2010-07-20, Rami Chowdhury wrote: > If you have a sufficiently recent version of Python, have you >considered time.strptime: >http://docs.python.org/library/time.html#time.strptime ? Given the documentation talks about "double leap seconds" which don't exist, why should this code be trusted?

Re: convert time to UTC seconds since epoch

2010-07-20 Thread Ian Kelly
On Tue, Jul 20, 2010 at 4:51 PM, Alexander wrote: >  On 21.07.2010 00:46, Rami Chowdhury wrote: >> On Jul 20, 2010, at 12:26 , Alexander wrote: >> >>> Hi, list >>> >>> How with python standard library to convert string like '-MM-DD >>> mm:HH:SS ZONE' to seconds since epoch in UTC? ZONE may be

Re: convert time to UTC seconds since epoch

2010-07-20 Thread Alexander
On 21.07.2010 00:46, Rami Chowdhury wrote: > On Jul 20, 2010, at 12:26 , Alexander wrote: > >> Hi, list >> >> How with python standard library to convert string like '-MM-DD >> mm:HH:SS ZONE' to seconds since epoch in UTC? ZONE may be literal time >> zone or given in explicit way like +0100. >

Re: convert time to UTC seconds since epoch

2010-07-20 Thread Rami Chowdhury
On Jul 20, 2010, at 12:26 , Alexander wrote: > Hi, list > > How with python standard library to convert string like '-MM-DD > mm:HH:SS ZONE' to seconds since epoch in UTC? ZONE may be literal time > zone or given in explicit way like +0100. If you have a sufficiently recent version of Pytho

Re: convert time string in UTC to time in local time

2007-03-10 Thread Paul Boddie
[EMAIL PROTECTED] wrote: > I'm guessing there is an easy way to do this but I keep going around > in circles in the documentation. > > I have a time stamp that looks like this (corresponding to UTC time): > > start_time = '2007-03-13T15:00:00Z' > > I want to convert it to my local time. > > start_t