DateTime
class in package klyn.time

    public class DateTime extends Object implements ValueType:

Object
└ DateTime
All Implemented Interfaces: ValueType

Represents a date and time, including timezone information.

This class provides methods to create and manipulate date/time values. It supports initialization from a timestamp or from individual date/time components.

    import klyn.time
    dt = DateTime(year=2023, month=10, day=5, hour=14, minute=30, second=45)
    print(dt.toString())  # 2023-10-05 14:30:45

@since 1.0

Properties

Modifier and Type | Member | Description
--- | --- | ---
public readonly property | day `day as Int:` | Day component.
public readonly property | dayOfWeek `dayOfWeek as Int:` | Returns the day of the week (0 = Sunday, 1 = Monday, .
public readonly property | dayOfYear `dayOfYear as Int:` | Returns the day of the year (1.
public readonly property | hour `hour as Int:` | Hour component.
public readonly property | minute `minute as Int:` | Minute component.
public readonly property | month `month as Int:` | Month component (1.
public static readonly property | now `now as DateTime:` | Returns the current date and time.
public readonly property | second `second as Int:` | Second component.
public readonly property | timeZone `timeZone as TimeZone:` | Timezone of this date/time.
public readonly property | timestamp `timestamp as Timestamp:` | Returns the timestamp representation of this DateTime object.
public readonly property | totalSeconds `totalSeconds as Double:` | No summary.
public readonly property | usecond `usecond as Int:` | Microsecond component.
public readonly property | year `year as Int:` | Year component.

Properties inherited from Object: type
Constructors

Modifier and Type | Member | Description
--- | --- | ---
public | DateTime `DateTime(epochSeconds as Double, timeZone as TimeZone = TimeZone.UTC):` | Constructs a DateTime from an epoch timestamp expressed in seconds.
public | DateTime `DateTime(text as String, timeZone as TimeZone = TimeZone.local):` | Constructs a DateTime by parsing an ISO 8601 date-time string (e.
public | DateTime `DateTime(timestamp as Timestamp, timeZone as TimeZone = TimeZone.UTC):` | Constructs a DateTime from a timestamp.
public | DateTime `DateTime(year as Int = 1970, month as Int = 1, day as Int = 1, hour as Int = 0, minute as Int = 0, second as Int = 0, usecond as Int = 0, timeZone as TimeZone = TimeZone.local):` | Constructs a DateTime from individual date/time components.

Methods

Modifier and Type | Member | Description
--- | --- | ---
public override | toString `toString(format as String = "%Y-%m-%d %H:%M:%S") as String:` | Returns a string representation of this DateTime object using the default locale.
public | toString `toString(format as String, locale as Locale) as String:` | Returns a string representation of this DateTime object using a specific locale.

Methods inherited from Object: fromJson, toDict, toJson, toString, toXml
Operators

Modifier and Type | Member | Description
--- | --- | ---
public static | operator+(dt as DateTime, duration as Duration) as DateTime: | Adds a duration to this DateTime object.
public static | operator-(dt as DateTime, duration as Duration) as DateTime: | Subtracts a duration from this DateTime object.
public static | operator-(left as DateTime, right as DateTime) as Duration: | Subtracts one DateTime object from another.