cdindex.time_utilities module

time_utilities.py: Utility functions for converting time formats.

cdindex.time_utilities.datetime_from_timestamp(ts)[source]

Convert a Unix timestamp to a datetime.

Given a Unix timestamp, this function returns a datetime. Input is assumed to be Greenwich Mean Time (GMT) and local time zone information is ignored. The function is useful for converting integers, which are required by some functions in the module, to more human readable dates.

Parameters:ts (int) – A Unix timestamp.
Returns:A datetime.
Return type:datetime
cdindex.time_utilities.main()[source]
cdindex.time_utilities.timestamp_from_datetime(dt)[source]

Convert a datetime to a Unix timestamp.

Given a datetime, this function returns a Unix timestamp. Input is assumed to be Greenwich Mean Time (GMT) and local time zone information is ignored. The function is useful for converting dates to integers, which are required as input to some other functions in the module.

Parameters:dt (datetime) – A datetime.
Returns:A Unix timestamp.
Return type:int