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


Groups > comp.lang.python > #32478

Re: date and time comparison how to

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 <d@davea.name>
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 <d@davea.name>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120912 Thunderbird/15.0.1
MIME-Version 1.0
To noydb <jenn.duerr@gmail.com>
Subject Re: date and time comparison how to
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>
In-Reply-To <d6043deb-74d8-4c3a-9661-228ab7f17291@googlegroups.com>
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 <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.3084.1351589734.27098.python-list@python.org> (permalink)
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

Show key headers only | View raw


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!  
>>
>>> <snip>
>>
>>
> 
> 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

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