set_time_resolution
- typhon.utils.set_time_resolution(datetime_obj, resolution)[source]
Set the resolution of a python datetime object.
- Parameters:
datetime_obj – A python datetime object.
resolution – A string indicating the required resolution.
- Returns:
A datetime object truncated to resolution.
Examples:
from typhon.utils.time import set_time_resolution, to_datetime dt = to_datetime("2017-12-04 12:00:00") # datetime.datetime(2017, 12, 4, 12, 0) new_dt = set_time_resolution(dt, "day") # datetime.datetime(2017, 12, 4, 0, 0) new_dt = set_time_resolution(dt, "month") # datetime.datetime(2017, 12, 1, 0, 0)