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


Groups > comp.lang.python > #34623

Re: strptime - dates formatted differently on different computers

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <jenn.duerr@gmail.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; 'locale': 0.07; 'parser': 0.07; 'pypi': 0.07; 'works.': 0.07; 'python': 0.09; 'accuracy.': 0.09; 'throw': 0.09; 'thrown': 0.09; 'timestamps': 0.09; 'to:addr:comp.lang.python': 0.09; 'cc:addr:python-list': 0.10; 'steve': 0.13; 'dec': 0.15; '(windows': 0.16; 'doesnt': 0.16; 'it..': 0.16; 'subject:dates': 0.16; 'mon,': 0.16; 'string': 0.17; 'wrote:': 0.17; 'handles': 0.18; 'module': 0.19; 'bit': 0.21; 'import': 0.21; 'greg': 0.22; 'parse': 0.22; 'sorry,': 0.22; 'cc:2**0': 0.23; 'purposes': 0.23; "i've": 0.23; 'cc:no real name:2**0': 0.24; 'tried': 0.25; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; '---': 0.26; 'common': 0.26; 'necessary.': 0.27; '-0700,': 0.29; "i'm": 0.29; 'function': 0.30; 'december': 0.32; '11,': 0.33; 'crazy': 0.33; 'handle': 0.33; 'received:google.com': 0.34; 'thanks': 0.34; 'whatever': 0.35; 'formats': 0.35; "won't": 0.35; 'received:209.85': 0.35; 'michael': 0.36; 'but': 0.36; 'anything': 0.36; 'should': 0.36; 'why': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'sure': 0.38; 'called': 0.39; 'lost': 0.60; 'kind': 0.61; 'offer': 0.65; 'american': 0.73; 'donald': 0.84; 'newbie,': 0.84
Newsgroups comp.lang.python
Date Tue, 11 Dec 2012 06:52:29 -0800 (PST)
In-Reply-To <mailman.715.1355214941.29569.python-list@python.org>
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=198.102.41.250; posting-account=1oR0EAoAAAANUNTZzTcJtVHDa9M690er
References <d564ab7b-9259-4460-813a-10a41e0fcd64@googlegroups.com> <50C6C5E7.1030300@gmail.com> <mailman.715.1355214941.29569.python-list@python.org>
User-Agent G2/1.0
X-Google-Web-Client true
X-Google-IP 198.102.41.250
MIME-Version 1.0
Subject Re: strptime - dates formatted differently on different computers
From noydb <jenn.duerr@gmail.com>
To comp.lang.python@googlegroups.com
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding quoted-printable
Cc python-list@python.org
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>
Message-ID <mailman.730.1355237559.29569.python-list@python.org> (permalink)
Lines 42
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1355237559 news.xs4all.nl 6944 [2001:888:2000:d::a6]:45416
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:34623

Show key headers only | View raw


On Tuesday, December 11, 2012 3:35:29 AM UTC-5, Greg Donald wrote:
> On Mon, Dec 10, 2012 at 10:34:31PM -0700, Michael Torrie wrote:
> 
> > I use a module I got from pypi called dateutil.  It has a nice submodule
> 
> > called parser that can handle a variety of date formats with good
> 
> > accuracy.  Not sure how it works, but it handles all the common American
> 
> > date formats I've thrown at it.
> 
> 
> 
> from dateutil.parser import parse
> 
> dt = parse( whatever )
> 
> 
> 
> I've throw all kind of date and timestamps at it.. have yet to see anything it won't parse.
> 
> 
> 
> 
> 
> --
> 
> Greg Donald


Thanks - I tried this (dateutil.parser import parsed...), and it works.  I'm skeptical of it working for any crazy date string thrown at it, but for my purposes it should suffice -- and my purposes for now was purely just curiousity on how to handle if it became necessary.

I tried figuring out Steve D'Aprano's solution above on my system (windows 7, python 2.7) - no luck.  Sorry, I am a newbie, so I'm a bit lost on this --- my locale module doesnt offer a nl_langinfo function -- why would this be?

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


Thread

strptime - dates formatted differently on different computers noydb <jenn.duerr@gmail.com> - 2012-12-10 13:18 -0800
  Re: strptime - dates formatted differently on different computers noydb <jenn.duerr@gmail.com> - 2012-12-10 13:22 -0800
  Re: strptime - dates formatted differently on different computers Dave Angel <d@davea.name> - 2012-12-10 16:36 -0500
    Re: strptime - dates formatted differently on different computers Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-12-11 02:07 +0000
  Re: strptime - dates formatted differently on different computers Michael Torrie <torriem@gmail.com> - 2012-12-10 22:34 -0700
  Re: strptime - dates formatted differently on different computers Chris Angelico <rosuav@gmail.com> - 2012-12-11 19:08 +1100
  Re: strptime - dates formatted differently on different computers Michael Torrie <torriem@gmail.com> - 2012-12-11 01:23 -0700
  Re: strptime - dates formatted differently on different computers Michael Torrie <torriem@gmail.com> - 2012-12-11 01:25 -0700
  Re: strptime - dates formatted differently on different computers Chris Angelico <rosuav@gmail.com> - 2012-12-11 19:32 +1100
  Re: strptime - dates formatted differently on different computers Greg Donald <gdonald@gmail.com> - 2012-12-11 02:35 -0600
    Re: strptime - dates formatted differently on different computers noydb <jenn.duerr@gmail.com> - 2012-12-11 06:52 -0800
    Re: strptime - dates formatted differently on different computers noydb <jenn.duerr@gmail.com> - 2012-12-11 06:52 -0800
    Re: strptime - dates formatted differently on different computers Marc Christiansen <usenet@solar-empire.de> - 2012-12-11 21:18 +0100
      Re: strptime - dates formatted differently on different computers Greg Donald <gdonald@gmail.com> - 2012-12-11 23:28 -0600
    Re: strptime - dates formatted differently on different computers Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-12-12 05:05 +0000
      Re: strptime - dates formatted differently on different computers Greg Donald <gdonald@gmail.com> - 2012-12-11 23:29 -0600

csiph-web