Path: csiph.com!usenet.pasdenom.info!news.albasani.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!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.013 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'formatting': 0.07; 'input,': 0.09; 'timestamps': 0.09; 'above?': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'input.': 0.16; 'oct': 0.16; 'tweak': 0.16; 'string': 0.17; 'wrote:': 0.17; 'integer': 0.17; 'input': 0.18; '(or': 0.18; 'received:209.85.214.174': 0.21; 'testing': 0.24; 'header:In- Reply-To:1': 0.25; 'possible,': 0.27; 'message- id:@mail.gmail.com': 0.27; 'actual': 0.28; 'directly,': 0.29; "i'm": 0.29; "skip:' 10": 0.30; 'seconds': 0.30; 'to:addr:python- list': 0.33; 'received:google.com': 0.34; 'compared': 0.35; 'pm,': 0.35; 'sometimes': 0.35; 'received:209.85': 0.35; 'something': 0.35; 'there': 0.35; 'but': 0.36; 'compare': 0.36; 'should': 0.36; 'turn': 0.36; 'received:209': 0.37; 'subject:: ': 0.38; 'sure': 0.38; 'instead': 0.39; 'to:addr:python.org': 0.39; 'received:209.85.214': 0.39; 'easily': 0.39; 'header:Received:5': 0.40; 'your': 0.60; '30,': 0.62; 'referred': 0.62; '1970,': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=6mf98Ph/vbMZOdCdo6xn8sZkWamLhP4QlZKN43naWnY=; b=0MOj8BHSdjJdOOAbsAph/m7/SvlP0KWh6vnq2+nsNWKB/co3DwkbSi6xpIEaqyaVlk 02L4V4DQIL0rxtbDA5OMOT8jL3NKDNQABexr48eRWBT+A/LwVozoKg/q5qhzQdxCzyC9 7MmBLRRQyy+74t6Eq1rcv0GCkNhJWsBefPSEhw4H07wKUYCTAk2ld1Ua4ss+3aFUiyg6 cZ4r4x/EBP4eUAhhFa1/xFHvCr/u86930+jq0NY5BlCI54XwnH1kdUS8rZtd95jvI/uJ 3h6iTvyMxoEi4vPusde5Fn8LZuEdmJJ8VtLOwKhivbJw/7oNBGnOaSC7wM8IJTzTwc80 4W/Q== MIME-Version: 1.0 In-Reply-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> Date: Tue, 30 Oct 2012 17:12:47 +1100 Subject: Re: date and time comparison how to From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list 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: 17 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1351577570 news.xs4all.nl 6971 [2001:888:2000:d::a6]:33829 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:32467 On Tue, Oct 30, 2012 at 3:20 PM, noydb wrote: > 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 late= r), so like '10292012213000' (oct 29, 2012 9:30pm). How would you get that= input into a format to compare with dt above? Instead of formatting your other date to match the input, turn the input into something you can easily manipulate - preferably, Unix time (seconds since 1970, sometimes referred to as a "time_t"). Once both your timestamps are integer (or float) seconds since a known epoch, they can be compared directly, as numbers. You're already pretty much there with strptime. Poke around with that and play with your format string and you should have it. But you may need to tweak it to match your actual input. ChrisA