4.41. kink/datetime/OFFSET

Provides `offset` type, which is offset of civil time from UTC.

4.41.1. type offset

A offset is an offset of civil time from UTC in Java Time-Scale, with minute precision.

The range of offset is [UTC-18:00, UTC+18:00].

Example:

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

:Utc <- OFFSET.new(0)
stdout.print_line(Utc.sign.repr)    # => "+"
stdout.print_line(Utc.hour.repr)    # => 0
stdout.print_line(Utc.minute.repr)  # => 0

:Plus_8_45 <- OFFSET.new(525)
stdout.print_line(Plus_8_45.sign.repr)    # => "+"
stdout.print_line(Plus_8_45.hour.repr)    # => 8
stdout.print_line(Plus_8_45.minute.repr)  # => 45

:Minus_2_30 <- OFFSET.new(-150)
stdout.print_line(Minus_2_30.sign.repr)   # => "-"
stdout.print_line(Minus_2_30.hour.repr)   # => 2
stdout.print_line(Minus_2_30.minute.repr) # => 30

4.41.1.1. O.op_eq(Arg)

Two offsets are equal when they have the same total minutes.

4.41.1.2. O.total_minutes

“total_minutes” method returns the offset as minutes.

4.41.1.3. O.sign

“sign” method returns the sign mark of the offset.

The method returns "+" if the offset is greater than or equal to zero, or "-" if it is less than zero.

For example,

• Returns "+" for +00:00

• Returns "+" for +08:45

• Returns "-" for -02:30

4.41.1.4. O.hour

“hour” method returns the hour part of the offset when it is analyzed to the sign, hours and minutes.

For example,

• Returns 0 for +00:00

• Returns 8 for +08:45

• Returns 2 for -02:30

Postcondition:

• The result is an int num which is in the range [0, 18]

4.41.1.5. O.minute

“minute” method returns the minute part of the offset when it is analyzed to the sign, hours and minutes.

For example,

• Returns 0 for +00:00

• Returns 45 for +08:45

• Returns 30 for -02:30

Postcondition:

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

4.41.1.6. O.repr

`repr` method returns the string representation of the offset.

For example,

• Returns "(offset +00:00)" for +00:00

• Returns "(offset +08:45)" for +08:45

• Returns "(offset -02:30)" for -02:30

4.41.2. OFFSET.new(Total_minutes)

`new` fun makes a `offset` val with Total_minutes as the offset in minutes from UTC.

Preconditions:

• Total_minutes must be an int num

• Total_minutes must be greater than or equal to -1080 (UTC-18:00)

• Total_minutes must be less than or equal to 1080 (UTC+18:00)

4.41.3. OFFSET.is?(Val)

OFFSET.is? returns whether Val is a `offset` val.