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


Groups > comp.lang.python > #32460

Re: date and time comparison how to

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.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.032
X-Spam-Evidence '*H*': 0.94; '*S*': 0.00; 'chime': 0.09; 'mtime': 0.09; 'skip:t 60': 0.09; 'subtract': 0.09; 'cc:addr:python-list': 0.10; 'thread': 0.11; 'modification': 0.15; '10:13': 0.16; 'string': 0.17; 'wrote:': 0.17; 'import': 0.21; 'os,': 0.22; 'cc:2**0': 0.23; 'seems': 0.23; 'cc:no real name:2**0': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header :User-Agent:1': 0.26; 'ago': 0.27; 'guess': 0.27; 'rest': 0.28; 'gary': 0.29; 'way?': 0.29; '(and': 0.32; 'anyone': 0.33; 'entered': 0.34; 'pm,': 0.35; 'there': 0.35; 'compare': 0.36; 'method': 0.36; "i'll": 0.36; 'two': 0.37; 'subject:: ': 0.38; 'files': 0.38; 'received:192': 0.39; 'skip:" 10': 0.40; 'received:192.168': 0.40; 'hours': 0.66; 'header:Reply-To:1': 0.68; 'received:74.208': 0.71; 'reply-to:no real name:2**0': 0.72; 'difference.': 0.84; 'lastly,': 0.84; 'received:74.208.4.194': 0.84; 'examine': 0.95
Date Mon, 29 Oct 2012 23:11:29 -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>
In-Reply-To <6f437b0f-1fe5-49c6-98e3-7be615d04858@googlegroups.com>
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding 7bit
X-Provags-ID V02:K0:9C9pS+xtya98iKVOBRGK8IXiOed3ZjFIbLeBK9m74UV LeA9sYqH8l8ZbgSxoBz+SbqEQrmfLtGLsjvow25hmHvm132Pvs ueeEUvx3/2eh0wxaWv8Tt/T0jPa/R8MW3Eq6MSha/qK8KsgzsF ZU1hmyatI5zTa83omtWdLYytBPrr3OaUjVod+gu5+87+NAUFX1 C7Oo7XSDX7mNNqFIZRKUKt8ijwA3n4JV5X23NHtX6Z9ALEBdA6 rQM9Iu4JKuDk3zvmeTdvCvEKg7lH/NvskTWGryewOLT7Zh78cg ML0itCFYmcHugl6K1Xj6Fiw0eYagWGzowTv2Feu1ghjoFesCw= =
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.3068.1351566714.27098.python-list@python.org> (permalink)
Lines 34
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1351566714 news.xs4all.nl 6853 [2001:888:2000:d::a6]:59092
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:32460

Show key headers only | View raw


On 10/29/2012 10:13 PM, noydb wrote:
> I guess I get there eventually!  
> This seems to work
>
>     pdf_timeStamp = time.strftime("%m%d%y%H%M%S",time.localtime(os.path.getmtime(pdf)))
>     intermediateTime = time.strptime(pdf_timeStamp, "%m%d%y%H%M%S")
>     pdfFile_compareTime = time.mktime(intermediateTime)
>
> (and I'll do the same to the user entered date-n-time and then compare)
>
>
> Lastly, so can anyone chime in and tell me if this is a good method or not?  Is there a better way?

Please read the rest of the thread in particular the message 3 hours ago
from Gary Herron

                import datetime, os, stat
                mtime = os.lstat(filename)[stat.ST_MTIME]   // the files
modification time
                dt = datetime.datetime.fromtimestamp(mtime)

Now you can compare two datetimes simply by
   if dt1 < dt2:

Or you can subtract them, and examine the difference.

What's the need for all that string conversion stuff?



-- 

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