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

Newsgroups comp.lang.python
Date 2012-12-11 06:52 -0800
References <d564ab7b-9259-4460-813a-10a41e0fcd64@googlegroups.com> <50C6C5E7.1030300@gmail.com> <mailman.715.1355214941.29569.python-list@python.org>
Subject Re: strptime - dates formatted differently on different computers
From noydb <jenn.duerr@gmail.com>
Message-ID <mailman.730.1355237559.29569.python-list@python.org> (permalink)

Show all headers | 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