ws.utils.datetime_ module

ws.utils.datetime_.parse_date(date)

Converts ISO 8601 dates generated by the MediaWiki API into datetime.datetime objects.

This will return a time in what the wiki thinks is UTC. Plan accordingly for bad server configurations.

Parameters

date – string ISO 8601 date representation

Returns

datetime.datetime object

ws.utils.datetime_.format_date(date)

An inverse function to parse_date().

Parameters

date (datetime.datetime) – timestamp to format

Returns

str representation of the timestamp

ws.utils.datetime_.range_by_days(first, last)

Generate a list of datetime.date objects with consecutive items differing by 1 day.

Parameters
Returns

a list of datetime.date objects

ws.utils.datetime_.range_by_months(first, last)

Generate a list of datetime.date objects with consecutive items differing by 1 month.

Parameters
Returns

a list of datetime.date objects

ws.utils.datetime_.round_to_seconds(dt)

Rounds the given datetime.datetime object to the nearest whole second.