The openstack_dashboard.openstack.common.timeutils ModuleΒΆ

Time related utilities and helper functions.

openstack_dashboard.openstack.common.timeutils.advance_time_delta(timedelta)[source]

Advance overridden time using a datetime.timedelta.

openstack_dashboard.openstack.common.timeutils.advance_time_seconds(seconds)[source]

Advance overridden time by seconds.

openstack_dashboard.openstack.common.timeutils.clear_time_override()[source]

Remove the overridden time.

openstack_dashboard.openstack.common.timeutils.delta_seconds(before, after)[source]

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).

openstack_dashboard.openstack.common.timeutils.is_newer_than(after, seconds)[source]

Return True if after is newer than seconds.

openstack_dashboard.openstack.common.timeutils.is_older_than(before, seconds)[source]

Return True if before is older than seconds.

openstack_dashboard.openstack.common.timeutils.is_soon(dt, window)[source]

Determines if time is going to happen in the next window seconds.

Parameters:
  • dt – the time
  • window – minimum seconds to remain to consider the time not soon
Returns:

True if expiration is within the given duration

openstack_dashboard.openstack.common.timeutils.iso8601_from_timestamp(timestamp)[source]

Returns a iso8601 formatted date from timestamp.

openstack_dashboard.openstack.common.timeutils.isotime(at=None, subsecond=False)[source]

Stringify time in ISO 8601 format.

openstack_dashboard.openstack.common.timeutils.marshall_now(now=None)[source]

Make an rpc-safe datetime with microseconds.

Note: tzinfo is stripped, but not required for relative times.

openstack_dashboard.openstack.common.timeutils.normalize_time(timestamp)[source]

Normalize time in arbitrary timezone to UTC naive object.

openstack_dashboard.openstack.common.timeutils.parse_isotime(timestr)[source]

Parse time from ISO 8601 format.

openstack_dashboard.openstack.common.timeutils.parse_strtime(timestr, fmt='%Y-%m-%dT%H:%M:%S.%f')[source]

Turn a formatted time back into a datetime.

openstack_dashboard.openstack.common.timeutils.set_time_override(override_time=None)[source]

Overrides utils.utcnow.

Make it return a constant time or a list thereof, one at a time.

Parameters:override_time – datetime instance or list thereof. If not given, defaults to the current UTC time.
openstack_dashboard.openstack.common.timeutils.strtime(at=None, fmt='%Y-%m-%dT%H:%M:%S.%f')[source]

Returns formatted utcnow.

openstack_dashboard.openstack.common.timeutils.total_seconds(delta)[source]

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.

openstack_dashboard.openstack.common.timeutils.unmarshall_time(tyme)[source]

Unmarshall a datetime dict.

openstack_dashboard.openstack.common.timeutils.utcnow()[source]

Overridable version of utils.utcnow.

openstack_dashboard.openstack.common.timeutils.utcnow_ts()[source]

Timestamp version of our utcnow function.

Previous topic

The openstack_dashboard.openstack.common.importutils Module

Next topic

The openstack_dashboard.openstack.common.policy Module

This Page