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


Groups > comp.lang.python > #32467

Re: date and time comparison how to

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 <rosuav@gmail.com>
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 <d6043deb-74d8-4c3a-9661-228ab7f17291@googlegroups.com>
References <50e576ea-2ebe-4340-954e-6c23b5885680@googlegroups.com> <508F1973.2030907@digipen.edu> <mailman.3061.1351558251.27098.python-list@python.org> <6101355b-ae00-4482-96ee-ed60f5cb465f@googlegroups.com> <85ea1841-6849-4970-b08b-5c7bbb7bba14@googlegroups.com> <6f437b0f-1fe5-49c6-98e3-7be615d04858@googlegroups.com> <mailman.3068.1351566714.27098.python-list@python.org> <d6043deb-74d8-4c3a-9661-228ab7f17291@googlegroups.com>
Date Tue, 30 Oct 2012 17:12:47 +1100
Subject Re: date and time comparison how to
From Chris Angelico <rosuav@gmail.com>
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 <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.3074.1351577570.27098.python-list@python.org> (permalink)
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

Show key headers only | View raw


On Tue, Oct 30, 2012 at 3:20 PM, noydb <jenn.duerr@gmail.com> 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 later), 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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

date and time comparison how to noydb <jenn.duerr@gmail.com> - 2012-10-29 16:13 -0700
  Re: date and time comparison how to Gary Herron <gherron@digipen.edu> - 2012-10-29 17:04 -0700
  Re: date and time comparison how to MRAB <python@mrabarnett.plus.com> - 2012-10-30 00:50 +0000
    Re: date and time comparison how to noydb <jenn.duerr@gmail.com> - 2012-10-29 18:47 -0700
      Re: date and time comparison how to noydb <jenn.duerr@gmail.com> - 2012-10-29 19:02 -0700
        Re: date and time comparison how to noydb <jenn.duerr@gmail.com> - 2012-10-29 19:13 -0700
          Re: date and time comparison how to Dave Angel <d@davea.name> - 2012-10-29 23:11 -0400
            Re: date and time comparison how to noydb <jenn.duerr@gmail.com> - 2012-10-29 21:20 -0700
              Re: date and time comparison how to Chris Angelico <rosuav@gmail.com> - 2012-10-30 17:12 +1100
              Re: date and time comparison how to Dave Angel <d@davea.name> - 2012-10-30 05:35 -0400
            Re: date and time comparison how to noydb <jenn.duerr@gmail.com> - 2012-10-29 21:20 -0700
          Re: date and time comparison how to MRAB <python@mrabarnett.plus.com> - 2012-10-30 03:30 +0000
        Re: date and time comparison how to noydb <jenn.duerr@gmail.com> - 2012-10-29 19:13 -0700
      Re: date and time comparison how to noydb <jenn.duerr@gmail.com> - 2012-10-29 19:02 -0700
    Re: date and time comparison how to noydb <jenn.duerr@gmail.com> - 2012-10-29 18:47 -0700
  RE: date and time comparison how to "Prasad, Ramit" <ramit.prasad@jpmorgan.com> - 2012-10-31 21:04 +0000
  Re: date and time comparison how to Adam  Tauno Williams <awilliam@whitemice.org> - 2012-11-02 07:22 -0400

csiph-web