utctime.UtcTime

class utctime.UtcTime(year: int, month: int = 1, day: int = 1, hour: int = 0, minute: int = 0, second: int = 0, microsecond: int = 0)

Wrapper class for datetime.datetime that’s always in UTC.

It behaves in a similar manner and with similar conventions.

You can use it as a type, use the constructor, or use one of the static methods to create utctime.UtcTime instances.

__init__(year: int, month: int = 1, day: int = 1, hour: int = 0, minute: int = 0, second: int = 0, microsecond: int = 0)

Construct new utctime.UtcTime with a given date/time.

All fields but year are optional.

Unlike the datetime.datetime constructor, the datetime.datetime.tzinfo argument may not be specified.

Methods

__init__(year[, month, day, hour, minute, ...])

Construct new utctime.UtcTime with a given date/time.

copy_from(other)

Return a utctime.UtcTime from another utctime.UtcTime or UTC datetime.datetime object.

iso()

Returns an ISO 8601 formatted date-time string.

now()

Current UTC date and time.

parse_iso(iso8601)

Parse an ISO 8601 date-time string and returns a utctime.UtcTime instance.

replace([year, month, day, hour, minute, ...])

Replace any of the date/time fields.

timestamp()

Seconds since the epoch (1970) as a float, as per datetime.datetime.timestamp().

todatetime()

Converts back to a regular datetime.datetime with a UTC timezone.

Attributes

day

1 - 31 (depending on the month) as per datetime.datetime.day

hour

0 - 23 as per datetime.datetime.hour

microsecond

0 - 999999 as per datetime.datetime.microsecond

minute

0 - 59 as per datetime.datetime.minute

month

1 - 12 as per datetime.datetime.month

second

0 - 59 as per datetime.datetime.second

year

1 - 9999 as per datetime.datetime.year