4.37. kink/datetime/DATETIME

Provides `datetime` type.

4.37.1. type datetime

A `datetime` val represents date and time without timezone or UTC offset, in the ISO 8601 calendar system without inserting leap seconds.

A `datetime` val is represented to nanosecond precision. The subsecond part is represented within “second” attribute, together with integral second part.

The range of `datetime` is [0001-00-00T00:00:00.000000000, 9999-12-31T23:59:59.999999999].

Example:

:DATETIME.require_from('kink/datetime/')

:Dt <- DATETIME.new(2020 1 10 23 14 25.123456789)
stdout.print_line(Dt.year.repr)   # => 2020
stdout.print_line(Dt.month.repr)  # => 1
stdout.print_line(Dt.day.repr)    # => 10
stdout.print_line(Dt.hour.repr)   # => 23
stdout.print_line(Dt.minute.repr) # => 13
stdout.print_line(Dt.second.repr) # => 25.123456789
stdout.print_line(Dt.day_of_week.repr)  # => DAY_OF_WEEK.friday

4.37.1.1. Dt.year

“year” method returns the year part of Dt.

Postcondition:

• The result is an int num, in the range [1, 9999].

4.37.1.2. Dt.month

“month” method returns the month part of Dt.

Postcondition:

• The result is an int num, in the range [1, 12].

4.37.1.3. Dt.day

“day” method returns the day part of Dt.

Postcondition:

• The result is an int num, in the range [1, 31].

4.37.1.4. Dt.hour

“hour” method returns the hour part of Dt.

Postcondition:

• The result is an int num, in the range [0, 23].

4.37.1.5. Dt.minute

“minute” method returns the minute part of Dt.

Postcondition:

• The result is an int num, in the range [0, 59].

4.37.1.6. Dt.second

“second” method returns the second part of Dt.

Postcondition:

• The result is a num with scale=9, in the range [0.000000000, 59.999999999].

4.37.1.7. Dt.day_of_week

“day_of_week” method returns the day of week corresponding to the date of Dt.

Postcondition:

• The result is a day_of_week. See kink/datetime/DAY_OF_WEEK.

4.37.1.8. Dt1 < Dt2, Dt1 <= Dt2, Dt1 != Dt2, Dt1 == Dt2, Dt1 >= Dt2, Dt1 > Dt2

`datetime` values can be compared each other by comparison operators.

When a `datetime` X represents civil time which precedes the civil time represented by the other `datetime` Y, X is considered less than Y.

4.37.1.9. Dt.repr

“repr” returns a str representation of Dt, such as "Date_time(2020-01-10T23:07:04.123456789)".

4.37.2. DATETIME.new(Year Month Day Hour Minute Second)

`new` fun makes a `datetime` val, with the speicifed attributes.

• Year must be an int num in the range [1, 9999].

• Month must be an int num in the range [1, 12].

• Day must be an int num.

• The combination of Year, Month and Day must be a valid date in ISO 8601 calendar system.

• Hour must be an int num in the range [0, 23].

• Minute must be an int num in the range [0, 59].

• Second must be a num with scale<=9 in the range [0.000000000, 59.999999999].

4.37.3. DATETIME.is?(Val)

DATETIME.is? returns whether Val is a `datetime` val.