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


Groups > comp.lang.python > #32533

RE: date and time comparison how to

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeder2.ecngs.de!ecngs!feeder.ecngs.de!border1.nntp.ams.giganews.com!nntp.giganews.com!usenetcore.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <ramit.prasad@jpmorgan.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'python)': 0.05; 'completeness': 0.07; 'filesystem': 0.09; 'mtime': 0.09; 'output,': 0.09; 'received:155': 0.09; 'looked': 0.10; 'modification': 0.15; 'appreciated!': 0.16; 'comparison.': 0.16; 'disclaimers': 0.16; 'disclaimers,': 0.16; 'disk.': 0.16; 'doesnt': 0.16; "file's": 0.16; 'from:addr:jpmorgan.com': 0.16; 'received:155.180': 0.16; 'received:155.180.234': 0.16; 'received:155.180.234.122': 0.16; 'received:159.53': 0.16; 'received:bankone.net': 0.16; 'received:exchad.jpmchase.net': 0.16; 'received:jpmchase.com': 0.16; 'received:jpmchase.net': 0.16; 'received:se3.svr.bankone.net': 0.16; 'received:svr.bankone.net': 0.16; 'securities,': 0.16; 'url:disclosures': 0.16; 'url:jpmorgan': 0.16; 'wrote:': 0.17; 'module,': 0.17; 'module': 0.19; 'to:name:python-list@python.org': 0.20; 'all,': 0.21; 'import': 0.21; 'os,': 0.22; 'received:169.254': 0.24; 'tried': 0.25; 'header:In-Reply-To:1': 0.25; 'accuracy': 0.27; 'newer': 0.27; 'correct': 0.28; 'gary': 0.29; 'things,': 0.29; 'received:169': 0.29; 'file': 0.32; 'could': 0.32; 'to:addr:python-list': 0.33; 'entered': 0.34; 'list': 0.35; 'path': 0.35; 'pm,': 0.35; 'something': 0.35; 'add': 0.36; 'compare': 0.36; 'charset:us-ascii': 0.36; 'turn': 0.36; 'subject:: ': 0.38; 'files': 0.38; 'sure': 0.38; 'to:addr:python.org': 0.39; 'help': 0.40; 'information,': 0.63; 'url:email': 0.63; 'legal': 0.65; 'subject': 0.66; 'purchase': 0.67; 'as:': 0.75; 'sale': 0.76; 'received:169.254.8': 0.84
X-DKIM OpenDKIM Filter v2.1.3 sz1.jpmchase.com q9VL51hU022361
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=jpmorgan.com; s=smtpout; t=1351717501; bh=wTgOgAGbGcTGMqMA2sz8/kK58OupZXktbJKM24ub1EU=; h=From:To:Subject:Date:Message-ID:References:In-Reply-To: Content-Transfer-Encoding:MIME-Version:Content-Type; b=fC9R4dvYaNCKTOHbNbys6W+qGdHq5MI9lb2GU2ltEk+vHRe+gPbxYp5E86i7ubZfm mE6HBSByanDI+2xaoePv7oG1jsPmA8KO3lEC4OrGcDaR0+WXIu/4yULculNDmpWTZV Tkl7/eF0HeoxP4UPDHmj0zjuFN6B7owb3mHTmub4=
From "Prasad, Ramit" <ramit.prasad@jpmorgan.com>
To "python-list@python.org" <python-list@python.org>
Subject RE: date and time comparison how to
Thread-Topic date and time comparison how to
Thread-Index AQHNtitBld+0SMxJJEKzLbI7EzSHi5fROtuAgAKuJNA=
Date Wed, 31 Oct 2012 21:04:38 +0000
References <50e576ea-2ebe-4340-954e-6c23b5885680@googlegroups.com> <508F1973.2030907@digipen.edu>
In-Reply-To <508F1973.2030907@digipen.edu>
Accept-Language en-US
Content-Language en-US
X-MS-Has-Attach
X-MS-TNEF-Correlator
x-originating-ip [10.67.79.47]
Content-Transfer-Encoding quoted-printable
MIME-Version 1.0
X-DLP-FWD Yes
Content-Type text/plain; charset="us-ascii"
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.3125.1351717511.27098.python-list@python.org> (permalink)
Lines 22
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1351717511 news.xs4all.nl 6870 [2001:888:2000:d::a6]:52388
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:32533

Show key headers only | View raw


Gary Herron wrote:
> On 10/29/2012 04:13 PM, noydb wrote:
> > All,
> >
> > I need help with a date and time comparison.
> >
> > Say a user enters a date-n-time and a file on disk.  I want to compare the date and time of the file to the
> entered date-n-time; if the file is newer than the entered date-n-time, add the file to a list to process.
> >
> > How best to do?  I have looked at the datetime module, tried a few things, no luck.
> >
> > Is os.stat a part of it?  Tried, not sure of the output, the st_mtime/st_ctime doesnt jive with the file's
> correct date and time.  ??
> >
> > Any help would be appreciated!
> 
> Use the datetime module (distributed with Python) to compare date/times.
> 
> You can turn a filesystem time into a datetime with something like the
> following:
>                  import datetime, os, stat
>                  mtime = os.lstat(filename)[stat.ST_MTIME]   // the
> files modification time
>                  dt = datetime.datetime.fromtimestamp(mtime)
> 

You could also write that as:

datetime.datetime.fromtimestamp( os.path.getmtime( path ) )


Ramit P


This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  

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