My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
Examples  

Featured
Updated Feb 4, 2010 by bear42

import parsedatetime.parsedatetime as pdt import parsedatetime.parsedatetime_consts as pdc

# create an instance of Constants class so we can override some of the defaults

c = pdc.Constants()

# create an instance of the Calendar class and pass in our Constants # object instead of letting it create a default

p = pdt.Calendar(c)

# parse "tomorrow" and return the result

result = p.parse("tomorrow")

# parseDate() is a helper function that bypasses all of the # natural language stuff and just tries to parse basic dates # but using the locale information

result = p.parseDate("4/4/80")

# parseDateText() is a helper function that tries to parse # long-form dates using the locale information

result = p.parseDateText("March 5th, 1980")

Comment by maciej.b...@gmail.com, Jun 8, 2009

It looks like some lines are being merged where they shouldn't, for example there are two import statements in the first line.

Comment by tsagias@gmail.com, Sep 13, 2009

The two import lines missing:

import parsedatetime.parsedatetime as pdt
import parsedatetime.parsedatetime_consts as pdc
Comment by mm.mpa...@gmail.com, Feb 1, 2010

@maciej.blizinski: You are right, just copy and paste without thinking about someone who has to read this.

if you didnt know:

with three curly braces in front
and three curly braces after the code

you produce a readable text here.

It is easy.

Comment by philip.r...@gmail.com, Feb 5, 2010

When you are using times, do not use a period to separate hours and minutes, you must use a colon.

e.g. "today at 1:50PM"


Sign in to add a comment
Powered by Google Project Hosting