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: 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 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: In-Reply-To: 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 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. > 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() See the chart on http://docs.python.org/2/library/time