Time related utilities and helper functions.
A immutable stopwatch split.
See: http://en.wikipedia.org/wiki/Stopwatch for what this is/represents.
Duration from stopwatch start.
Seconds from last split (or the elapsed time if no prior split).
A simple timer/stopwatch helper class.
Inspired by: apache-commons-lang java stopwatch.
Not thread-safe (when a single watch is mutated by multiple threads at the same time). Thread-safe when used by a single thread (not shared) or when operations are performed in a thread-safe manner on these objects by wrapping those operations with locks.
Returns how many seconds have elapsed.
Returns if the watch has expired (ie, duration provided elapsed).
Returns how many seconds are left until the watch expires.
Parameters: | return_none (boolean) – when True instead of raising a RuntimeError when no duration has been set this call will return None instead. |
---|
Restarts the watch from a started/stopped state.
Resumes the watch from a stopped state.
Captures a split/elapsed since start time (and doesn’t stop).
Accessor to all/any splits that have been captured.
Starts the watch (if not already started).
NOTE(harlowja): resets any splits previously captured (if any).
Stops the watch.
Advance overridden time using a datetime.timedelta.
Advance overridden time by seconds.
Remove the overridden time.
Return the difference between two timing objects.
Compute the difference in seconds between two date, time, or datetime objects (as a float, to microsecond resolution).
Return True if after is newer than seconds.
Return True if before is older than seconds.
Determines if time is going to happen in the next window seconds.
Parameters: |
|
---|---|
Returns: | True if expiration is within the given duration |
Returns an iso8601 formatted date from timestamp.
Stringify time in ISO 8601 format.
Make an rpc-safe datetime with microseconds.
Note: tzinfo is stripped, but not required for relative times.
Normalize time in arbitrary timezone to UTC naive object.
Parse time from ISO 8601 format.
Turn a formatted time back into a datetime.
Overrides utils.utcnow.
Make it return a constant time or a list thereof, one at a time.
See oslo_utils.fixture.TimeFixture.
Parameters: | override_time – datetime instance or list thereof. If not given, defaults to the current UTC time. |
---|
Returns formatted utcnow.
Return the total seconds of datetime.timedelta object.
Compute total seconds of datetime.timedelta, datetime.timedelta doesn’t have method total_seconds in Python2.6, calculate it manually.
Unmarshall a datetime dict.
Overridable version of utils.utcnow.
Timestamp version of our utcnow function.