phenopacket_mapper.data_standards.date module

class phenopacket_mapper.data_standards.date.Date(year: int = 0, month: int = 0, day: int = 0, hour: int = 0, minute: int = 0, second: int = 0)[source]

Bases: object

Data class for Date

year: int
month: int
day: int
hour: int
minute: int
second: int
iso_8601_datestring() str[source]

Returns the date in ISO 8601 format

Example: “2021-06-02T16:52:15Z” Format: “{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z” Definition: The format for this is “{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z” where {year} is

always expressed using four digits while {month}, {day}, {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution), are optional. The “Z” suffix indicates the timezone (“UTC”); the timezone is required.

formatted_string(fmt: str) str[source]

Returns the date in the specified format

Parameters:

fmt – the format as a string to return the date in

Returns:

the date in the specified format

static from_datetime(dt: datetime) Date[source]

Create a Date object from a datetime object

Parameters:

dt – the datetime object to create the Date object from

Returns:

the Date object created from the datetime object

static from_iso_8601(iso_8601: str) Date[source]

Create a Date object from an ISO 8601 formatted string

Parameters:

iso_8601 – the ISO 8601 formatted string to create the Date object from

Returns:

the Date object created from the ISO 8601 formatted string