Parsing the string "in 2hrs"

5 views
Skip to first unread message

Fishtank

unread,
Dec 3, 2010, 3:41:24 PM12/3/10
to parsedatetime-dev
Hi,
Thanks for the great package. As it should, pars "in 2hrs"
correctly returns the time 2hrs from *now*.

How can I set the base time ('current time') so that "in 2hrs" returns
a time
2hrs from the base time?


Cheers
J

bear

unread,
Dec 3, 2010, 3:51:24 PM12/3/10
to parsedat...@googlegroups.com

The parse function takes as an optional parameter what datetime to use
as the start/base time. You can see an example of this in the
tests/TestSimpleOffsets.py testHoursFromNow method.

for example:

s = datetime.datetime.now()
start = s.timetuple()

c.parse('in 5hrs', start)

where c is a pdt.Calendar() instance

>
>
> Cheers
> J
>
> --
> You received this message because you are subscribed to the Google Groups "parsedatetime-dev" group.
> To post to this group, send email to parsedat...@googlegroups.com.
> To unsubscribe from this group, send email to parsedatetime-...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/parsedatetime-dev?hl=en.
>
>

--
Bear

be...@xmpp.org (email)
bea...@gmail.com (xmpp, email)
be...@code-bear.com (xmpp, email)
http://code-bear.com/bearlog (weblog)

PGP Fingerprint = 9996 719F 973D B11B E111  D770 9331 E822 40B3 CD29

Saptarshi Joy Guha

unread,
Dec 7, 2010, 5:33:51 PM12/7/10
to parsedat...@googlegroups.com
Perfect. Thank you.

Saptarshi

Reply all
Reply to author
Forward
0 new messages