Data Types

In order to provide full compatibility with the Erbsland Configuration Language, this implementation provides a number of data types. The classes Time and DateTime extend the built-in datetime.time and datetime.datetime classes by adding nanosecond precision. The class TimeDelta simply combines a count with a time unit and provides conversion to datetime.timedelta, yet only for units that are supported by Python.

Interface

class Time(hour: int, minute: int, *, second: int = 0, microsecond: int = 0, nanosecond: int = 0, tzinfo=None, fold: int = 0)

Represents a time of day with nanosecond precision.

This class wraps datetime.time to carry nanoseconds when needed. Any further operation on this class drops the nanosecond precision.

property nanosecond: int

Nanosecond component of the time.

classmethod fromisoformat(time_string: str) Time

string -> time from a string in ISO 8601 format

elcl_format() str

Return the time formatted for ELCL.

The representation is based on ISO formatting with two changes:

  • Fractions use nanosecond precision.

  • An offset of +00:00 is rendered as z.

classmethod patch_iso_time(date_time_string: str) str

Patch an ISO time string to conform to ELCL format.

  • Remove trailing zeros from fractions.

  • Render an offset of +00:00 as z.

class DateTime(year: int, month: int, day: int, *, hour: int = 0, minute: int = 0, second: int = 0, microsecond: int = 0, nanosecond: int = 0, tzinfo=None, fold: int = 0)

Represents a combined date and time with nanosecond precision.

This class wraps datetime.datetime to carry nanoseconds when needed. Any operation on this class drops the nanosecond precision.

property nanosecond: int

Nanosecond component of the date-time.

classmethod fromisoformat(date_time_string: str) DateTime

string -> datetime from a string in most ISO 8601 formats

elcl_format() str

Return the date and time formatted for ELCL.

The representation is based on ISO formatting with two changes:

  • Fractions use nanosecond precision.

  • An offset of +00:00 is rendered as z.

classmethod patch_iso_time(date_time_string: str) str

Patch an ISO date-time string to conform to ELCL format.

  • Remove trailing zeros from fractions.

  • Render an offset of +00:00 as z.

class TimeDelta(count: int = 0, unit: TimeUnit = TimeUnit.SECOND)

A time span consisting of a count and a unit.

Variables:
  • count – Numeric value of the span.

  • unit – Unit associated with count.

to_test_text() str

Return a machine-readable representation used in tests.