469,352 Members | 2,154 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,352 developers. It's quick & easy.

string to datetime parser?

Is there a library which can parse strings and output a datetime
object? It should be as magical as possible and allow things like:
12:30
tomorrow
10.10.2005
02-28-00
28/03/95
1995-03-28
1996.Feb.29 (Thu) 16:45:23.7

Is there anything like that out there? My Google can't find anything
useful ...

Jan 9 '06 #1
5 1649
On 7 Jan 2006 21:00:34 -0800, "beza1e1"
<an*************@googlemail.com> wrote:
Is there a library which can parse strings and output a datetime
object? It should be as magical as possible and allow things like:
12:30
tomorrow
10.10.2005
02-28-00
28/03/95
1995-03-28
1996.Feb.29 (Thu) 16:45:23.7

Is there anything like that out there? My Google can't find anything
useful ...


There is a module called DateUtil which will do *most* of what you
want. (Possibly all).

I can't recall the URL, but google should turn it up for you.

All the best,
Fuzzyman
http://www.voidspace.org.uk/python/index.shtml
Jan 9 '06 #2
beza1e1 enlightened us with:
Is there a library which can parse strings and output a datetime
object?


If you're happy with a mx.DateTime object, take a look at its parser.

Sybren
--
The problem with the world is stupidity. Not saying there should be a
capital punishment for stupidity, but why don't we just take the
safety labels off of everything and let the problem solve itself?
Frank Zappa
Jan 9 '06 #3
"beza1e1" <an*************@googlemail.com> wrote:
Is there a library which can parse strings and output a datetime
object? It should be as magical as possible and allow things like:
12:30
tomorrow
10.10.2005
02-28-00
28/03/95


And given 10/03/95, is that a date in mid-March, or in early October?
--
- Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Jan 10 '06 #4
A good solution may be to specify a language to determine the order.
The default would be (something like) "en-US" and thus early October in
the example.

Jan 13 '06 #5
beza1e1 wrote:
Is there a library which can parse strings and output a datetime
object? It should be as magical as possible and allow things like:
12:30
tomorrow
10.10.2005
02-28-00
28/03/95
1995-03-28
1996.Feb.29 (Thu) 16:45:23.7

Is there anything like that out there? My Google can't find anything
useful ...


http://www.egenix.com/files/python/mxDateTime.html

--
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source (#1, Jan 13 2006)
Python/Zope Consulting and Support ... http://www.egenix.com/
mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/

__________________________________________________ ______________________

::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! ::::
Jan 13 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Robert Brewer | last post: by
4 posts views Thread by Keith Henderson | last post: by
11 posts views Thread by Rubic | last post: by
15 posts views Thread by morleyc | last post: by
11 posts views Thread by xyz | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.