parquet_time Derived Type

type, public :: parquet_time

A time of day, stored as nanoseconds since midnight, [0, 86400e9 - 1]. Holds any Parquet TIME unit (seconds/millis/micros/nanos) exactly. A default-initialized element is null.


Constructor

public interface parquet_time

Constructs a valid parquet_time from (hour, minute, second[, nanosecond]); aborts on invalid fields.

  • private impure elemental function time_new(hour, minute, second, nanosecond) result(res)

    Constructor specific for the parquet_time generic: builds a valid time element from (hour, minute, second[, nanosecond]); aborts on invalid fields.

    Arguments

    Type IntentOptional Attributes Name
    integer(kind=int32), intent(in) :: hour

    hour, 0..23.

    integer(kind=int32), intent(in) :: minute

    minute, 0..59.

    integer(kind=int32), intent(in) :: second

    second, 0..59.

    integer(kind=int32), intent(in), optional :: nanosecond

    sub-second part, 0..999999999 (default 0).

    Return Value type(parquet_time)

    the constructed element (valid).


Type-Bound Procedures

procedure, public :: set => time_set

Sets from validated (hour, minute, second[, nanosecond]).

  • private impure elemental subroutine time_set(self, hour, minute, second, nanosecond)

    Sets the element from validated time-of-day fields; marks it valid. Leap seconds (second == 60) are not representable (Parquet/Arrow TIME does not support them).

    Arguments

    Type IntentOptional Attributes Name
    class(parquet_time), intent(inout) :: self

    receives the time (marked valid).

    integer(kind=int32), intent(in) :: hour

    hour, 0..23.

    integer(kind=int32), intent(in) :: minute

    minute, 0..59.

    integer(kind=int32), intent(in) :: second

    second, 0..59.

    integer(kind=int32), intent(in), optional :: nanosecond

    sub-second part, 0..999999999 (default 0).

procedure, public :: get => time_get

Returns hour, minute, second[, nanosecond] (aborts on null).

  • private elemental subroutine time_get(self, hour, minute, second, nanosecond)

    Returns the time-of-day fields of the element; aborts on a null element.

    Arguments

    Type IntentOptional Attributes Name
    class(parquet_time), intent(in) :: self

    the element.

    integer(kind=int32), intent(out) :: hour

    hour, 0..23.

    integer(kind=int32), intent(out) :: minute

    minute, 0..59.

    integer(kind=int32), intent(out) :: second

    second, 0..59.

    integer(kind=int32), intent(out), optional :: nanosecond

    sub-second part, 0..999999999.

procedure, public :: hour => time_hour

Hour 0..23 (aborts on null).

  • private elemental function time_hour(self) result(res)

    Returns the hour (0..23); aborts on a null element.

    Arguments

    Type IntentOptional Attributes Name
    class(parquet_time), intent(in) :: self

    the element.

    Return Value integer(kind=int32)

procedure, public :: minute => time_minute

Minute 0..59 (aborts on null).

  • private elemental function time_minute(self) result(res)

    Returns the minute (0..59); aborts on a null element.

    Arguments

    Type IntentOptional Attributes Name
    class(parquet_time), intent(in) :: self

    the element.

    Return Value integer(kind=int32)

procedure, public :: second => time_second

Second 0..59 (aborts on null).

  • private elemental function time_second(self) result(res)

    Returns the second (0..59); aborts on a null element.

    Arguments

    Type IntentOptional Attributes Name
    class(parquet_time), intent(in) :: self

    the element.

    Return Value integer(kind=int32)

procedure, public :: nanosecond => time_nanosecond

Sub-second part 0..999999999 (aborts on null).

  • private elemental function time_nanosecond(self) result(res)

    Returns the sub-second part in nanoseconds (0..999999999); aborts on a null element.

    Arguments

    Type IntentOptional Attributes Name
    class(parquet_time), intent(in) :: self

    the element.

    Return Value integer(kind=int32)

procedure, public :: is_null => time_is_null

Whether the element is null (never aborts).

  • private elemental function time_is_null(self) result(res)

    Returns whether the element is null (the primary null guard; never aborts).

    Arguments

    Type IntentOptional Attributes Name
    class(parquet_time), intent(in) :: self

    the element.

    Return Value logical

procedure, public :: set_null => time_set_null

Marks the element null.

  • private impure elemental subroutine time_set_null(self)

    Marks the element null.

    Arguments

    Type IntentOptional Attributes Name
    class(parquet_time), intent(inout) :: self

    the element (reset to the null state).

procedure, public :: set_raw => time_set_raw

Sets raw ns-since-midnight (interop; marks valid).

  • private impure elemental subroutine time_set_raw(self, nanoseconds)

    Sets the raw nanoseconds-since-midnight directly (interop/advanced accessor; marks the element valid); aborts on a value outside a day.

    Arguments

    Type IntentOptional Attributes Name
    class(parquet_time), intent(inout) :: self

    receives the value (marked valid).

    integer(kind=int64), intent(in) :: nanoseconds

    nanoseconds since midnight, [0, 86400e9 - 1].

procedure, public :: raw => time_raw

Raw ns-since-midnight; 0 for a null element (interop).

  • private elemental function time_raw(self) result(res)

    Returns the raw nanoseconds-since-midnight, or 0 for a null element (interop/advanced accessor; never aborts -- validity travels separately via is_null).

    Arguments

    Type IntentOptional Attributes Name
    class(parquet_time), intent(in) :: self

    the element.

    Return Value integer(kind=int64)

procedure, public :: to_string => time_to_string

ISO-8601 "HH:MM:SS[.fraction]" (aborts on null).

  • private subroutine time_to_string(self, str)

    Writes the element as ISO-8601 "HH:MM:SS[.fraction]" (fraction omitted when zero, else the shortest of 3/6/9 digits that is exact); aborts on a null element. A subroutine for the same reason as parquet_date%to_string.

    Arguments

    Type IntentOptional Attributes Name
    class(parquet_time), intent(in) :: self

    the element.

    character(len=:), intent(out), allocatable :: str

    receives the formatted time.

procedure, public :: parse => time_parse

Sets from an ISO-8601 time string.

  • private impure elemental subroutine time_parse(self, str, success)

    Sets the element from an ISO-8601 time string "HH:MM:SS[.fraction]" (1..9 fraction digits). Failure handling matches parquet_date%parse: abort by default, or report via the optional success (leaving the element null).

    Arguments

    Type IntentOptional Attributes Name
    class(parquet_time), intent(out) :: self

    receives the parsed time (or null on caught failure).

    character(len=*), intent(in) :: str

    ISO-8601 time string.

    logical, intent(out), optional :: success

    .true. on success; absent => abort on failure.

generic, public :: operator(==) => time_eq

Equality (aborts on a null operand).

  • private elemental function time_eq(a, b) result(res)

    Equality specific; see the operator(==) generic. Aborts on a null operand.

    Arguments

    Type IntentOptional Attributes Name
    class(parquet_time), intent(in) :: a

    left operand.

    class(parquet_time), intent(in) :: b

    right operand.

    Return Value logical

generic, public :: operator(/=) => time_ne

Inequality (aborts on a null operand).

  • private elemental function time_ne(a, b) result(res)

    Inequality specific; see the operator(/=) generic. Aborts on a null operand.

    Arguments

    Type IntentOptional Attributes Name
    class(parquet_time), intent(in) :: a

    left operand.

    class(parquet_time), intent(in) :: b

    right operand.

    Return Value logical

generic, public :: operator(<) => time_lt

Ordering (aborts on a null operand).

  • private elemental function time_lt(a, b) result(res)

    Less-than specific; see the operator(<) generic. Aborts on a null operand.

    Arguments

    Type IntentOptional Attributes Name
    class(parquet_time), intent(in) :: a

    left operand.

    class(parquet_time), intent(in) :: b

    right operand.

    Return Value logical

generic, public :: operator(<=) => time_le

Ordering (aborts on a null operand).

  • private elemental function time_le(a, b) result(res)

    Less-or-equal specific; see the operator(<=) generic. Aborts on a null operand.

    Arguments

    Type IntentOptional Attributes Name
    class(parquet_time), intent(in) :: a

    left operand.

    class(parquet_time), intent(in) :: b

    right operand.

    Return Value logical

generic, public :: operator(>) => time_gt

Ordering (aborts on a null operand).

  • private elemental function time_gt(a, b) result(res)

    Greater-than specific; see the operator(>) generic. Aborts on a null operand.

    Arguments

    Type IntentOptional Attributes Name
    class(parquet_time), intent(in) :: a

    left operand.

    class(parquet_time), intent(in) :: b

    right operand.

    Return Value logical

generic, public :: operator(>=) => time_ge

Ordering (aborts on a null operand).

  • private elemental function time_ge(a, b) result(res)

    Greater-or-equal specific; see the operator(>=) generic. Aborts on a null operand.

    Arguments

    Type IntentOptional Attributes Name
    class(parquet_time), intent(in) :: a

    left operand.

    class(parquet_time), intent(in) :: b

    right operand.

    Return Value logical

generic, public :: operator(-) => time_diff, time_sub_ns_i32, time_sub_ns_i64

Difference or ns offset (wraps; aborts on a null operand or a >24h offset magnitude).

  • private elemental function time_diff(a, b) result(res)

    Difference specific; see the operator(-) generic. Nanoseconds, exact (bounded to +-1 day of ns since both operands lie in [0, 86400e9 - 1]); aborts on a null operand.

    Arguments

    Type IntentOptional Attributes Name
    class(parquet_time), intent(in) :: a

    left (later) operand.

    class(parquet_time), intent(in) :: b

    right (earlier) operand.

    Return Value integer(kind=int64)

  • private impure elemental function time_sub_ns_i32(self, n) result(res)

    int32 specific of operator(-); see time_offset_ns_impl. The 24h magnitude guard is moot for this kind (int32's own range never reaches 86400e9 ns), kept only for symmetry with the int64 specific.

    Arguments

    Type IntentOptional Attributes Name
    class(parquet_time), intent(in) :: self

    the element to shift.

    integer(kind=int32), intent(in) :: n

    ns to subtract.

    Return Value type(parquet_time)

    self shifted back by n ns, wrapped.

  • private impure elemental function time_sub_ns_i64(self, n) result(res)

    int64 specific of operator(-); see time_offset_ns_impl. Aborts if abs(n) exceeds 24h of nanoseconds (checked on the raw, not-yet-negated input, so negating it afterwards can never overflow).

    Arguments

    Type IntentOptional Attributes Name
    class(parquet_time), intent(in) :: self

    the element to shift.

    integer(kind=int64), intent(in) :: n

    ns to subtract.

    Return Value type(parquet_time)

    self shifted back by n ns, wrapped.

generic, public :: operator(+) => time_add_ns_i32, time_add_ns_i64

Ns offset (wraps; aborts on a null operand or a >24h offset magnitude).

  • private impure elemental function time_add_ns_i32(self, n) result(res)

    int32 specific of operator(+); see time_offset_ns_impl. The 24h magnitude guard is moot for this kind (int32's own range never reaches 86400e9 ns), kept only for symmetry with the int64 specific.

    Arguments

    Type IntentOptional Attributes Name
    class(parquet_time), intent(in) :: self

    the element to shift.

    integer(kind=int32), intent(in) :: n

    ns to add.

    Return Value type(parquet_time)

    self shifted forward by n ns, wrapped.

  • private impure elemental function time_add_ns_i64(self, n) result(res)

    int64 specific of operator(+); see time_offset_ns_impl. Aborts if abs(n) exceeds 24h of nanoseconds.

    Arguments

    Type IntentOptional Attributes Name
    class(parquet_time), intent(in) :: self

    the element to shift.

    integer(kind=int64), intent(in) :: n

    ns to add.

    Return Value type(parquet_time)

    self shifted forward by n ns, wrapped.

Source Code

    type :: parquet_time
        private
        integer(int64) :: nanoseconds = 0_int64 !! nanoseconds since midnight, [0, 86400e9 - 1].
        logical :: valid = .false.              !! .false. = null element (the default state).
    contains
        procedure :: set => time_set              !! Sets from validated (hour, minute, second[, nanosecond]).
        procedure :: get => time_get              !! Returns hour, minute, second[, nanosecond] (aborts on null).
        procedure :: hour => time_hour            !! Hour 0..23 (aborts on null).
        procedure :: minute => time_minute        !! Minute 0..59 (aborts on null).
        procedure :: second => time_second        !! Second 0..59 (aborts on null).
        procedure :: nanosecond => time_nanosecond !! Sub-second part 0..999999999 (aborts on null).
        procedure :: is_null => time_is_null      !! Whether the element is null (never aborts).
        procedure :: set_null => time_set_null    !! Marks the element null.
        procedure :: set_raw => time_set_raw      !! Sets raw ns-since-midnight (interop; marks valid).
        procedure :: raw => time_raw              !! Raw ns-since-midnight; 0 for a null element (interop).
        procedure :: to_string => time_to_string  !! ISO-8601 "HH:MM:SS[.fraction]" (aborts on null).
        procedure :: parse => time_parse          !! Sets from an ISO-8601 time string.
        procedure, private :: time_eq             !! == specific.
        procedure, private :: time_ne             !! /= specific.
        procedure, private :: time_lt             !! <  specific.
        procedure, private :: time_le             !! <= specific.
        procedure, private :: time_gt             !! >  specific.
        procedure, private :: time_ge             !! >= specific.
        generic :: operator(==) => time_eq        !! Equality (aborts on a null operand).
        generic :: operator(/=) => time_ne        !! Inequality (aborts on a null operand).
        generic :: operator(<) => time_lt         !! Ordering (aborts on a null operand).
        generic :: operator(<=) => time_le        !! Ordering (aborts on a null operand).
        generic :: operator(>) => time_gt         !! Ordering (aborts on a null operand).
        generic :: operator(>=) => time_ge        !! Ordering (aborts on a null operand).
        procedure, private :: time_diff           !! (time, time) specific of operator(-): ns difference.
        procedure, private :: time_sub_ns_i32     !! (time, integer(int32)) specific of operator(-).
        procedure, private :: time_sub_ns_i64     !! (time, integer(int64)) specific of operator(-).
        procedure, private :: time_add_ns_i32     !! (time, integer(int32)) specific of operator(+).
        procedure, private :: time_add_ns_i64     !! (time, integer(int64)) specific of operator(+).
        generic :: operator(-) => time_diff, time_sub_ns_i32, time_sub_ns_i64
        !! Difference or ns offset (wraps; aborts on a null operand or a >24h offset magnitude).
        generic :: operator(+) => time_add_ns_i32, time_add_ns_i64
        !! Ns offset (wraps; aborts on a null operand or a >24h offset magnitude).
    end type parquet_time