string to datetime parser?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • beza1e1

    #1

    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 ...

  • Fuzzyman

    #2
    Re: string to datetime parser?

    On 7 Jan 2006 21:00:34 -0800, "beza1e1"
    <andreas.zwinka u@googlemail.co m> wrote:
    [color=blue]
    >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 ...[/color]

    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

    Comment

    • Sybren Stuvel

      #3
      Re: string to datetime parser?

      beza1e1 enlightened us with:[color=blue]
      > Is there a library which can parse strings and output a datetime
      > object?[/color]

      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

      Comment

      • Tim Roberts

        #4
        Re: string to datetime parser?

        "beza1e1" <andreas.zwinka u@googlemail.co m> wrote:
        [color=blue]
        >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[/color]

        And given 10/03/95, is that a date in mid-March, or in early October?
        --
        - Tim Roberts, timr@probo.com
        Providenza & Boekelheide, Inc.

        Comment

        • beza1e1

          #5
          Re: string to datetime parser?

          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.

          Comment

          • M.-A. Lemburg

            #6
            Re: string to datetime parser?

            beza1e1 wrote:[color=blue]
            > 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 ...[/color]

            Provides the most natural and robust way of dealing with date/time values in Python.


            --
            Marc-Andre Lemburg
            eGenix.com

            Professional Python Services directly from the Source (#1, Jan 13 2006)[color=blue][color=green][color=darkred]
            >>> Python/Zope Consulting and Support ... http://www.egenix.com/
            >>> mxODBC.Zope.Dat abase.Adapter ... http://zope.egenix.com/
            >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/[/color][/color][/color]
            _______________ _______________ _______________ _______________ ____________

            ::: Try mxODBC.Zope.DA for Windows,Linux,S olaris,FreeBSD for free ! ::::

            Comment

            Working...