Create datastructures for times and dates that should be used to save dates and times in the database, especially for wdmmg.model.Entries.times
Like most parts of our data models date and date ranges are persisted denormalized. We save both single dates and date ranges in a a special kind of date range datastructure that conains
This works like this:
>>> from wdmmg.lib.times import for_year
>>> for_year(2011)
{'from': {'day': '20110301',
'month': '201103',
'parsed': datetime.datetime(2011, 3, 1, 0, 0),
'year': '2011'},
'to': {'day': '20110331',
'month': '201103',
'parsed': datetime.datetime(2011, 3, 31, 0, 0),
'year': '2011'},
'unparsed': '2011-03'}
Create a datastructure to save a span between tow datetimes in the database.
returns: a dict representing the timespan that can be saved into the database
Create a timespan() datastructure for a year
returns: see timespan()
Create a timespan() for a date or between a start and a end date, given as strings.
returns: see timespan()