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


Groups > comp.lang.python > #35983

Re: Using mktime to convert date to seconds since epoch - omitting elements from the tuple?

Path csiph.com!aioe.org!newsfeed.x-privat.org!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <davea@dejaviewphoto.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.024
X-Spam-Evidence '*H*': 0.95; '*S*': 0.00; 'revision': 0.05; 'svn': 0.05; 'tuple.': 0.09; 'url:calendar': 0.09; 'assume': 0.11; 'expects': 0.16; 'mktime': 0.16; 'subject: \n ': 0.16; 'url:time': 0.16; 'utc': 0.16; 'utc,': 0.16; 'string': 0.17; 'wrote:': 0.17; 'suggested': 0.20; 'header:In-Reply-To:1': 0.25; 'header:User- Agent:1': 0.26; '(e.g.': 0.27; 'am,': 0.27; 'easiest': 0.27; 'attempting': 0.29; 'convert': 0.29; "i'm": 0.29; 'seconds': 0.30; 'url:python': 0.32; 'problem': 0.33; 'to:addr:python-list': 0.33; 'hi,': 0.33; 'subject:?': 0.35; 'but': 0.36; 'url:org': 0.36; 'url:library': 0.36; 'subject:: ': 0.38; 'url:docs': 0.38; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'build': 0.39; 'received:192.168': 0.40; 'your': 0.60; 'times': 0.63; 'header :Reply-To:1': 0.68; 'received:74.208': 0.71; 'reply-to:no real name:2**0': 0.72; 'actually,': 0.84; 'received:74.208.4.194': 0.84; 'subject:Using': 0.84; 'victor': 0.84
Date Wed, 02 Jan 2013 09:06:51 -0500
From Dave Angel <davea@dejaviewphoto.com>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121011 Thunderbird/16.0.1
MIME-Version 1.0
To python-list@python.org
Subject Re: Using mktime to convert date to seconds since epoch - omitting elements from the tuple?
References <dfd18cf3-e2c0-4f0e-a4c1-a72924039a15@googlegroups.com>
In-Reply-To <dfd18cf3-e2c0-4f0e-a4c1-a72924039a15@googlegroups.com>
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding 7bit
X-Provags-ID V02:K0:6NFVwQZeVMPYYtQwxWsqIXBsYl+1yD5JNyVwW6H2+az +BoHnzzfhEHfLI77PtANcFAPrkUX3FwBNEJ2wdhe3F+g0E01mv HzL/oJSsXbYyrYx+s4J3boxjTV5TvSR4PwUTZ/SFsVnj23a2uP 3f/ojejrBMANX962immWwIRo2h+O3zaYXja5piH14ITpbZoyDK GESWK63kgm/yWNi9WplAd8HUs2W6n/5T1jEP2XXNuxNAXQAP9p zrGu7Y7A6qGS6Wb5Wu3kAKBGeGn3WLHGEPatQnC+YFDp1RggGt RVwct5zU40VZayav2yzycxLcYjj6neZhbOe41x70lzWJh4e4Q+ HDsywEP0anUuUfIUjsx8=
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
Reply-To davea@dejaviewphoto.com
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1564.1357135631.29569.python-list@python.org> (permalink)
Lines 25
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1357135631 news.xs4all.nl 6847 [2001:888:2000:d::a6]:52364
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:35983

Show key headers only | View raw


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 | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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