Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #35983
| Date | 2013-01-02 09:06 -0500 |
|---|---|
| From | Dave Angel <davea@dejaviewphoto.com> |
| Subject | Re: Using mktime to convert date to seconds since epoch - omitting elements from the tuple? |
| References | <dfd18cf3-e2c0-4f0e-a4c1-a72924039a15@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1564.1357135631.29569.python-list@python.org> (permalink) |
On 01/02/2013 03:01 AM, Victor Hooi wrote: > Hi, > > I'm using pysvn to checkout a specific revision based on date - pysvn will only accept a date in terms of seconds since the epoch. > > I'm attempting to use time.mktime() to convert a date (e.g. "2012-02-01) to seconds since epoch. > > According to the docs, mktime expects a 9-element tuple. Actually, it expects a struct_time, but will work with a tuple. The easiest way to build a struct_time from your string would be using time.strptime(), as suggested by Vlastimil. > <snip> The other problem is one of timezone. I would assume that svn would be expecting all times to be in UTC, so to convert from struct_time in UTC to seconds since epoch, you'd use calendar.timegm() <http://docs.python.org/2/library/calendar.html#calendar.timegm> See the chart on http://docs.python.org/2/library/time
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Using mktime to convert date to seconds since epoch - omitting elements from the tuple? Victor Hooi <victorhooi@gmail.com> - 2013-01-02 00:01 -0800
Re: Using mktime to convert date to seconds since epoch - omitting elements from the tuple? Vlastimil Brom <vlastimil.brom@gmail.com> - 2013-01-02 09:33 +0100
Re: Using mktime to convert date to seconds since epoch - omitting elements from the tuple? Dave Angel <davea@dejaviewphoto.com> - 2013-01-02 09:06 -0500
Re: Using mktime to convert date to seconds since epoch - omitting elements from the tuple? Roy Smith <roy@panix.com> - 2013-01-02 09:28 -0500
Re: Using mktime to convert date to seconds since epoch - omitting elements from the tuple? Chris Angelico <rosuav@gmail.com> - 2013-01-03 01:51 +1100
Re: Using mktime to convert date to seconds since epoch - omitting elements from the tuple? roy@panix.com (Roy Smith) - 2013-01-02 12:27 -0500
Re: Using mktime to convert date to seconds since epoch - omitting elements from the tuple? Chris Angelico <rosuav@gmail.com> - 2013-01-03 04:34 +1100
Re: Using mktime to convert date to seconds since epoch - omitting elements from the tuple? Dave Angel <d@davea.name> - 2013-01-02 12:44 -0500
Re: Using mktime to convert date to seconds since epoch - omitting elements from the tuple? Barry Scott <barry@barrys-emacs.org> - 2013-01-03 23:46 +0000
csiph-web