Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!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.037 X-Spam-Evidence: '*H*': 0.93; '*S*': 0.00; 'see.': 0.07; 'spec': 0.09; 'cc:addr:python-list': 0.10; '10:13': 0.16; 'above?': 0.16; 'quirks': 0.16; 'utc': 0.16; 'string': 0.17; 'wrote:': 0.17; '>>>': 0.18; 'input': 0.18; 'versions': 0.20; 'cc:2**0': 0.23; 'monday,': 0.23; 'cc:no real name:2**0': 0.24; 'testing': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header :User-Agent:1': 0.26; 'am,': 0.27; 'guess': 0.27; 'possible,': 0.27; 'optional': 0.29; 'case,': 0.29; "i'm": 0.29; "skip:' 10": 0.30; 'url:python': 0.32; 'environment,': 0.33; 'month,': 0.33; 'times.': 0.33; 'skip:d 20': 0.34; 'pm,': 0.35; 'there': 0.35; 'but': 0.36; 'url:org': 0.36; 'compare': 0.36; 'url:library': 0.36; 'operating': 0.36; 'possible': 0.37; 'october': 0.37; 'subject:: ': 0.38; 'url:docs': 0.38; 'sure': 0.38; 'received:192': 0.39; 'received:192.168': 0.40; 'your': 0.60; 'skip:u 10': 0.60; 'between': 0.63; 'header:Reply-To:1': 0.68; 'biggest': 0.71; 'received:74.208': 0.71; 'reply-to:no real name:2**0': 0.72; 'received:74.208.4.194': 0.84; 'angel': 0.93 Date: Tue, 30 Oct 2012 05:35:13 -0400 From: Dave Angel User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120912 Thunderbird/15.0.1 MIME-Version: 1.0 To: noydb Subject: Re: date and time comparison how to References: <50e576ea-2ebe-4340-954e-6c23b5885680@googlegroups.com> <508F1973.2030907@digipen.edu> <6101355b-ae00-4482-96ee-ed60f5cb465f@googlegroups.com> <85ea1841-6849-4970-b08b-5c7bbb7bba14@googlegroups.com> <6f437b0f-1fe5-49c6-98e3-7be615d04858@googlegroups.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:eFQ/XFvUrV5sgSA0zC3YAxDGRIZAuX2oDpLU3jCR0Ld T/N/vsBIlvOsBhqgBRYlTx6burrTVWOl9n9sQg+oBJxjNG9ve7 LmuvVBTymdaYlBeOOSjKpWUPiAgs5c0ITswizkVU87MIUI9weu m3J2aoGVwjpeSWXktfOEk3SX7kqV08A8rgk/IlBNeeXDJGjsZ8 hA7Zp9ulno2dCWPeNdxMSzYK9qION/vkpBI1tdYJ0b1KYWvZSG l8w0XQxNmjn6aitNt3dhh4CuGF3sn6nI1ER0W9GhgHaELtVL5u TDPE8UJH/k/SY4Ai0ZxoLERnEZcjHmdMtGh0rfVfY3/dbcGSg= = Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: d@davea.name 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: 35 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1351589734 news.xs4all.nl 6885 [2001:888:2000:d::a6]:47959 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:32478 On 10/30/2012 12:20 AM, noydb wrote: > On Monday, October 29, 2012 11:11:55 PM UTC-4, Dave Angel wrote: >> On 10/29/2012 10:13 PM, noydb wrote: >> >>> I guess I get there eventually! >> >>> >> >> > > okay, I see. > But for the user supplied date... I'm not sure of the format just yet... testing with a string for now (actual date-date might be possible, tbd later), so like '10292012213000' (oct 29, 2012 9:30pm). How would you get that input into a format to compare with dt above? > See http://docs.python.org/2/library/datetime.html There are a number of constructors for datetime. For example, now = datetime.datetime.now() spec = datetime.strptime(datstring, format) spec = datetime.datetime(year, month, day[, hour[, minute[, second[, microsecond) In each case, you have an optional tz for timezone. Or if possible, use utc versions of these functions to get "greenwich" times. tz is one of the biggest pains, and the quirks vary between operating systems and filesystems. If possible in your environment, use utcnow, utcfromtimestamp, etc. -- DaveA