klyn.time.DateTime.DateTime
constructor
public DateTime(text as String, timeZone as TimeZone = TimeZone.local)
Description

Constructs a DateTime by parsing a complete ISO 8601 date-time string. Fractional seconds may contain more than six digits; values beyond microsecond precision are truncated after the complete fraction has been validated. Calendar components use fixed-width ASCII digits: YYYY-MM-DD and HH:MM:SS. Explicit offsets accept both +HH:MM and +HHMM (or -).

Parameters
ParameterDescription
textThe ISO 8601 formatted string.
timeZoneThe time zone used when the text has no explicit offset.
Throws
  • ValueException if the text or one of its date/time components is invalid.
Example
import klyn.time
dt = DateTime("2025-04-18T14:30:00+02:00")
print(dt.year, dt.month, dt.day)