public class DateTime extends Object implements 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
| Modifier and Type | Member | Description |
|---|---|---|
| public readonly property | dayday as Int: |
Day component. |
| public readonly property | dayOfWeekdayOfWeek as Int: |
Returns the day of the week (0 = Sunday, 1 = Monday, . |
| public readonly property | dayOfYeardayOfYear as Int: |
Returns the day of the year (1. |
| public readonly property | hourhour as Int: |
Hour component. |
| public readonly property | minuteminute as Int: |
Minute component. |
| public readonly property | monthmonth as Int: |
Month component (1. |
| public static readonly property | nownow as DateTime: |
Returns the current date and time. |
| public readonly property | secondsecond as Int: |
Second component. |
| public readonly property | timeZonetimeZone as TimeZone: |
Timezone of this date/time. |
| public readonly property | timestamptimestamp as Timestamp: |
Returns the timestamp representation of this DateTime object. |
| public readonly property | totalSecondstotalSeconds as Double: |
No summary. |
| public readonly property | usecondusecond as Int: |
Microsecond component. |
| public readonly property | yearyear as Int: |
Year component. |
| Modifier and Type | Member | Description |
|---|---|---|
| public | DateTime | Constructs a DateTime from an epoch timestamp expressed in seconds. |
| public | DateTime | Constructs a DateTime by parsing an ISO 8601 date-time string (e. |
| public | DateTime | Constructs a DateTime from a timestamp. |
| public | DateTime | Constructs a DateTime from individual date/time components. |
| Modifier and Type | Member | Description |
|---|---|---|
| public override | toString | Returns a string representation of this DateTime object using the default locale. |
| public | toString | Returns a string representation of this DateTime object using a specific locale. |
| 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. |