Converting strings into usable time objects. The time objects, known as
Range have a number of methods that allow
you to easily change and manage your users input dynamically.
pip install timestring
Ranges are simply two Dates. The first date,
Range().end represent just that, a start and end to a period of time.
There are a couple reference points for Ranges.
x[ - - - - ]
Range('1 week')would be
today + 7 days
[ - - x - - ]
this monthis from start of month to end of month. Therefore today is included.
Range("today") in Range("this month") == True
x [ - - - - ]
next 3 weekstakes today and finds the start of next weeks and continues to contain 3 weeks.
Range("today") in Range("next 5 days") == Falseand
Range("tomorrow") in Range("next 5 days") == True
[ - - - - ] x
nextbut in the past
[ - - - - x ]
last 6 daystakes all of Today and encapsulates the last 6 days
Range("today") in Range("last 6 days") == True
The examples below all work with the following terms
year work for the examples below. fyi
Today is 5/14/2013
thiswill look at the references in its entirety
>> Range('this year') From 01/01/13 00:00:00 to 01/01/14 00:00:00
Notice how this year is from jan 1s to jan 1st of next year The full year, all 12 months, is this year
lastwill reference in the past
>> Range('1 year ago') From 01/01/11 00:00:00 to 01/01/12 00:00:00
1 year agois equivalent to
year ago, and
Note you add more years like this
5 years ago which will be
From 01/01/07 00:00:00 to 01/01/08 00:00:00
More examples / documentation coming soon.
timestring is licensed under the Apache Licence, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0.html).