eta.util.time
Utilities for recording and modifying times.
Functions
Get lower and upper bounds on the elapsed time between two timepoints. |
|
Return a POSIX timestamp corresponding to the time of the function call. |
|
Given a lower and upper bound datetime objects, create a ULF date+time record structure. |
|
Given a ULF date+time record structure, possibly containing "variables", return the lower and upper bound datetimes. |
|
Given a year/month/day/hour/minute/second tuple, possibly containing "variables", return the lower and upper bound datetimes. |
|
Given a lower and upper bound datetime objects, create a year/month/day/hour/minute/second tuple. |
Classes
A specific point in time. |
- class TimePoint(time=None)[source]
Bases:
object
A specific point in time.
- Parameters:
time (datetime, tuple[datetime, datetime], list[str], or None) –
Initialize with a given datetime, or otherwise use the current time. The following formats are supported:
datetime : a single instantaneous timestamp.
(datetime, datetime) : lower and upper bound timestamps for this time point.
[$, date+time, <year>, <month>, <day>, <hour>, <minute>, <second>] : a date+time record structure, where each slot may be either a number string or a variable string.
None : the time point will be initialized to the current time.
- lower
A timestamp for the lower bound on this timepoint.
- Type:
datetime
- upper
A timestamp for the upper bound on this timepoint.
- Type:
datetime
- to_num(bound='upper')[source]
Convert this TimePoint to a numerical POSIX representation (using the upper bound by default).
- get_elapsed(tp1, tp2)[source]
Get lower and upper bounds on the elapsed time between two timepoints.
- time_pair_from_tuple(tuple)[source]
Given a year/month/day/hour/minute/second tuple, possibly containing “variables”, return the lower and upper bound datetimes.
- time_pair_from_record(record)[source]
Given a ULF date+time record structure, possibly containing “variables”, return the lower and upper bound datetimes.
- tuple_from_time_pair(lower, upper)[source]
Given a lower and upper bound datetime objects, create a year/month/day/hour/minute/second tuple.