eta.util.time

Utilities for recording and modifying times.

Functions

get_elapsed

Get lower and upper bounds on the elapsed time between two timepoints.

now

Return a POSIX timestamp corresponding to the time of the function call.

record_from_time_pair

Given a lower and upper bound datetime objects, create a ULF date+time record structure.

time_pair_from_record

Given a ULF date+time record structure, possibly containing "variables", return the lower and upper bound datetimes.

time_pair_from_tuple

Given a year/month/day/hour/minute/second tuple, possibly containing "variables", return the lower and upper bound datetimes.

time_pair_p

time_record_p

time_tuple_p

tuple_from_time_pair

Given a lower and upper bound datetime objects, create a year/month/day/hour/minute/second tuple.

Classes

TimePoint

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

update(time=None)[source]

Update this TimePoint to the given time (or current if none is given).

to_num(bound='upper')[source]

Convert this TimePoint to a numerical POSIX representation (using the upper bound by default).

format()[source]

Format this TimePoint as a year/month/day/hour/minute/second representation.

format_date()[source]

Format this TimePoint as a human-readable year/month/day/hour/minute/second representation.

to_ulf()[source]

Convert this TimePoint to a ULF record structure.

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.

record_from_time_pair(lower, upper)[source]

Given a lower and upper bound datetime objects, create a ULF date+time record structure.

now()[source]

Return a POSIX timestamp corresponding to the time of the function call.