util Module

Util module for datetime handling.

util.date_format(datetime_obj, url_format=False)[source]

Put date in expected ISO serialized format without microseconds.

Parameters :

datetime_obj : datetime.datetime

The date to format into DATETIME_FMT format.

Returns :

datetime_str : string

The string version of the provided datetime object.

Notes

Both date functions belong in a utility class, but creating one for just these two functions is a bit much. They can live in base_handler for now.

Examples

>>> import util
>>> util.date_format(datetime.datetime.utcnow())
'2013-02-26T19:50:43.912'
util.parse_date(datetime_str, url_format=False)[source]

Return datetime object from expected ISO serialized format.

Parameters :

datetime_str : string

The ISO formatted date to convert back to a datetime object.

Returns :

datetime_obj : datetime.datetime

The datetime object represented by the provided string.

Examples

>>> import util
>>> util.parse_date('2013-02-26T19:50:43.912')
datetime.datetime(2013, 2, 26, 19, 50, 43, 912000)
util.system_time()[source]

Previous topic

user_server_test Module

Next topic

util_test Module

This Page