string to datetime parser?

Discussion in 'Python' started by beza1e1, Jan 8, 2006.

  1. beza1e1

    beza1e1 Guest

    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 ...
    beza1e1, Jan 8, 2006
    #1
    1. Advertising

  2. beza1e1

    Fuzzyman Guest

    On 7 Jan 2006 21:00:34 -0800, "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 ...


    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
    Fuzzyman, Jan 9, 2006
    #2
    1. Advertising

  3. 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
    Sybren Stuvel, Jan 9, 2006
    #3
  4. beza1e1

    Tim Roberts Guest

    "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


    And given 10/03/95, is that a date in mid-March, or in early October?
    --
    - Tim Roberts,
    Providenza & Boekelheide, Inc.
    Tim Roberts, Jan 10, 2006
    #4
  5. beza1e1

    beza1e1 Guest

    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.
    beza1e1, Jan 13, 2006
    #5
  6. 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 ! ::::
    M.-A. Lemburg, Jan 13, 2006
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Christos TZOTZIOY Georgiou
    Replies:
    3
    Views:
    691
    Christos TZOTZIOY Georgiou
    Sep 13, 2003
  2. Tim Peters
    Replies:
    0
    Views:
    524
    Tim Peters
    Sep 9, 2003
  3. mp
    Replies:
    1
    Views:
    379
    John Machin
    Jul 28, 2006
  4. Martin
    Replies:
    0
    Views:
    330
    Martin
    Dec 27, 2008
  5. Replies:
    2
    Views:
    745
    M.-A. Lemburg
    Jan 6, 2009
Loading...

Share This Page