task_script_utils.datetime_parser.ts_datetime module#

class TSDatetime(datetime_: datetime, subseconds: str | None = None)[source]#

Bases: object

TSDatetime wraps the parsed datetime and subsecond values and provide formatting functions like tsformat and isoformat

property subseconds: str | None#

Subseconds represent fractional part of seconds value that was parsed from raw datetime as string. eg: In 05-26-1991 12:12:23.000000023, 000000023 as string would represent subseconds. Subseconds is None when it is not present in raw datetime string

property tzinfo: tzinfo#

Returns tzinfo for the stored datetime object

property datetime: datetime#

Return a new datetime object after replacing microseconds with self._subseconds in self._datetime. subseconds needs to be truncated to 6 digits

tsformat() str[source]#

Returns datetime string in Tetrascience’s ISO8601 DateTime format

isoformat() str[source]#

Returns datetime string in ISO format with offset values

change_fold(new_fold: int | None)[source]#

Replace the fold value of stored datetime object if needed.