473,466 Members | 1,445 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 1727
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Robert Brewer | last post by:
Anyone else tired of typing date-addition logic when iterating? It would be nice if the datetime package had something like: def iterdates(first, last): for day in range((last - first).days +...
16
by: PK9 | last post by:
I have a string variable that holds the equivalent of a DateTime value. I pulled this datetime from the database and I want to strip off the time portion before displaying to the user. I am...
2
by: Samuel | last post by:
Hello, I am trying to convert a local time into UTC ISO8601, then parse it back into local time. I tried the following: ---------------------- #!/usr/bin/python import time import datetime...
4
by: Keith Henderson | last post by:
I have an xml document loaded into a string that I need to parse. below is the first few elements in the xml string. <?xml version="1.0" standalone="yes"?> <xs:schema id="NewDataSet" xmlns=""...
11
by: Rubic | last post by:
I was a little surprised to recently discover that datetime has no method to input a string value. PEP 321 appears does not convey much information, but a timbot post from a couple years ago...
15
by: morleyc | last post by:
Hi, i would like to remove a number of characters from my string (\t \r \n which are throughout the string), i know regex can do this but i have no idea how. Any pointers much appreciated. Chris
3
by: gregcm | last post by:
I've got a custom control that is trying to allow the user to enter a DateTime in a definable format and I was wondering if there was an easy way to alter the look of said control based on the...
11
by: xyz | last post by:
I have a string 16:23:18.659343 131.188.37.230.22 131.188.37.59.1398 tcp 168 for example lets say for the above string 16:23:18.659343 -- time 131.188.37.230 -- srcaddress 22 ...
14
by: Arjen | last post by:
Hi, I have a string with this value 07/11/2008. As you see no time included. How can I parse this string to a datetime variable? I tried to do this but I get the exception that the format is...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.