parquet_date Derived Type

type, public :: parquet_date

A calendar date (proleptic Gregorian), stored as days since 1970-01-01 -- identical to the physical value of a Parquet DATE / Arrow date32 column. A default-initialized element is null. Range: about +-5.8 million years.


Constructor

public interface parquet_date

Constructs a valid parquet_date from (year, month, day); aborts on an invalid civil date (the structure constructor itself is unavailable outside this module -- components are private -- so this generic takes its place).

  • private impure elemental function date_new(year, month, day) result(res)

    Constructor specific for the parquet_date generic: builds a valid date element from (year, month, day); aborts on an invalid civil date.

    Arguments

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

    calendar year.

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

    month, 1..12.

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

    day of month.

    Return Value type(parquet_date)

    the constructed element (valid).


Type-Bound Procedures

procedure, public :: set => date_set

Sets from a validated (year, month, day).

  • private impure elemental subroutine date_set(self, year, month, day)

    Sets the element from civil fields (proleptic Gregorian), validating month, day, and the representable range; marks it valid.

    Arguments

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

    receives the date (marked valid).

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

    calendar year.

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

    month, 1..12.

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

    day of month, 1..days_in_month.

procedure, public :: get => date_get

Returns year, month, day (aborts on null).

  • private elemental subroutine date_get(self, year, month, day)

    Returns the civil fields of the element; aborts on a null element.

    Arguments

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

    the element.

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

    calendar year.

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

    month, 1..12.

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

    day of month.

procedure, public :: year => date_year

Calendar year (aborts on null).

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

    Returns the calendar year; aborts on a null element.

    Arguments

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

    the element.

    Return Value integer(kind=int32)

procedure, public :: month => date_month

Calendar month 1..12 (aborts on null).

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

    Returns the calendar month (1..12); aborts on a null element.

    Arguments

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

    the element.

    Return Value integer(kind=int32)

procedure, public :: day => date_day

Day of month 1..31 (aborts on null).

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

    Returns the day of month (1..31); aborts on a null element.

    Arguments

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

    the element.

    Return Value integer(kind=int32)

procedure, public :: is_null => date_is_null

Whether the element is null (never aborts).

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

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

    Arguments

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

    the element.

    Return Value logical

procedure, public :: set_null => date_set_null

Marks the element null.

  • private impure elemental subroutine date_set_null(self)

    Marks the element null.

    Arguments

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

    the element (reset to the null state).

procedure, public :: set_raw => date_set_raw

Sets the raw day count (interop; marks valid).

  • private impure elemental subroutine date_set_raw(self, days)

    Sets the raw day count directly (interop/advanced accessor; marks the element valid).

    Arguments

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

    receives the value (marked valid).

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

    days since 1970-01-01 (the Parquet DATE value).

procedure, public :: raw => date_raw

Raw day count; 0 for a null element (interop).

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

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

    Arguments

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

    the element.

    Return Value integer(kind=int32)

generic, public :: set_mjd => date_set_mjd_i32, date_set_mjd_i64

Sets from an integer Modified Julian Date.

  • private impure elemental subroutine date_set_mjd_i32(self, mjd)

    int32 specific of set_mjd; see the set_mjd generic.

    Arguments

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

    receives the date (marked valid).

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

    integer Modified Julian Date.

  • private impure elemental subroutine date_set_mjd_i64(self, mjd)

    int64 specific of set_mjd: sets the element from an integer Modified Julian Date (MJD 0 = 1858-11-17); aborts if out of the representable range.

    Arguments

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

    receives the date (marked valid).

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

    integer Modified Julian Date.

procedure, public :: to_mjd => date_to_mjd

Integer Modified Julian Date (aborts on null).

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

    Returns the integer Modified Julian Date (MJD 0 = 1858-11-17); aborts on a null element.

    Arguments

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

    the element.

    Return Value integer(kind=int64)

procedure, public :: to_string => date_to_string

ISO-8601 "YYYY-MM-DD" (aborts on null).

  • private subroutine date_to_string(self, str)

    Writes the element as ISO-8601 "YYYY-MM-DD" (years 0..9999 zero-padded to 4 digits; a leading '-' and more digits otherwise); aborts on a null element. A subroutine (not a function) so this never returns character(len=:), allocatable as a function result -- see "Build and compiler notes" in CLAUDE.md for why.

    Arguments

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

    the element.

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

    receives the formatted date.

procedure, public :: parse => date_parse

Sets from an ISO-8601 date string.

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

    Sets the element from an ISO-8601 date string "[-]YYYY-MM-DD". On failure (not parseable as a valid civil date): error stop by default; if success is present, no abort happens -- success is set .false. and the element is left null (a defined state) instead. (This procedure's header line -- and five others in this file: date_new, time_parse, time_new, ts_parse, ts_new_civil -- never register as "hit" in gcov, even though every other line of each one's body does, including their own error stop lines, which only execute on the actual abort path this file's error-scenario tests specifically trigger. That proves each procedure genuinely runs; the header line itself just isn't attributed a hit by gcov for these six specifically (no common dummy-argument shape distinguishes them from this file's other, correctly-attributed procedure headers -- e.g. ts_set_civil, same impure elemental + optional-argument shape, IS attributed normally). Treated as the same class of line-attribution artifact as the documented end module/end submodule exclusion in CLAUDE.md, not a real gap -- see the coverage note in feature_temporal.md.)

    Arguments

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

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

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

    ISO-8601 date string.

    logical, intent(out), optional :: success

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

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

Equality (aborts on a null operand).

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

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

    Arguments

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

    left operand.

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

    right operand.

    Return Value logical

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

Inequality (aborts on a null operand).

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

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

    Arguments

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

    left operand.

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

    right operand.

    Return Value logical

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

Ordering (aborts on a null operand).

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

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

    Arguments

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

    left operand.

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

    right operand.

    Return Value logical

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

Ordering (aborts on a null operand).

  • private elemental function date_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_date), intent(in) :: a

    left operand.

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

    right operand.

    Return Value logical

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

Ordering (aborts on a null operand).

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

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

    Arguments

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

    left operand.

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

    right operand.

    Return Value logical

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

Ordering (aborts on a null operand).

  • private elemental function date_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_date), intent(in) :: a

    left operand.

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

    right operand.

    Return Value logical

generic, public :: operator(-) => date_diff, date_sub_days_i32, date_sub_days_i64

Difference or day offset (aborts on a null operand / out-of-range result).

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

    Difference specific; see the operator(-) generic. Whole days, exact; aborts on a null operand.

    Arguments

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

    left (later) operand.

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

    right (earlier) operand.

    Return Value integer(kind=int64)

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

    int32 specific of operator(-); see date_offset_days_impl.

    Arguments

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

    the element to shift.

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

    days to subtract.

    Return Value type(parquet_date)

    self shifted back by n days.

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

    int64 specific of operator(-); see date_offset_days_impl.

    Arguments

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

    the element to shift.

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

    days to subtract.

    Return Value type(parquet_date)

    self shifted back by n days.

generic, public :: operator(+) => date_add_days_i32, date_add_days_i64

Day offset (aborts on a null operand / out-of-range result).

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

    int32 specific of operator(+); see date_offset_days_impl.

    Arguments

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

    the element to shift.

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

    days to add.

    Return Value type(parquet_date)

    self shifted forward by n days.

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

    int64 specific of operator(+); see date_offset_days_impl.

    Arguments

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

    the element to shift.

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

    days to add.

    Return Value type(parquet_date)

    self shifted forward by n days.

Source Code

    type :: parquet_date
        private
        integer(int32) :: days = 0_int32 !! days since 1970-01-01 (the Parquet DATE value).
        logical :: valid = .false.       !! .false. = null element (the default state).
    contains
        procedure :: set => date_set              !! Sets from a validated (year, month, day).
        procedure :: get => date_get              !! Returns year, month, day (aborts on null).
        procedure :: year => date_year            !! Calendar year (aborts on null).
        procedure :: month => date_month          !! Calendar month 1..12 (aborts on null).
        procedure :: day => date_day              !! Day of month 1..31 (aborts on null).
        procedure :: is_null => date_is_null      !! Whether the element is null (never aborts).
        procedure :: set_null => date_set_null    !! Marks the element null.
        procedure :: set_raw => date_set_raw      !! Sets the raw day count (interop; marks valid).
        procedure :: raw => date_raw              !! Raw day count; 0 for a null element (interop).
        procedure, private :: date_set_mjd_i32    !! int32 specific of set_mjd.
        procedure, private :: date_set_mjd_i64    !! int64 specific of set_mjd.
        generic :: set_mjd => date_set_mjd_i32, date_set_mjd_i64 !! Sets from an integer Modified Julian Date.
        procedure :: to_mjd => date_to_mjd        !! Integer Modified Julian Date (aborts on null).
        procedure :: to_string => date_to_string  !! ISO-8601 "YYYY-MM-DD" (aborts on null).
        procedure :: parse => date_parse          !! Sets from an ISO-8601 date string.
        procedure, private :: date_eq             !! == specific.
        procedure, private :: date_ne             !! /= specific.
        procedure, private :: date_lt             !! <  specific.
        procedure, private :: date_le             !! <= specific.
        procedure, private :: date_gt             !! >  specific.
        procedure, private :: date_ge             !! >= specific.
        generic :: operator(==) => date_eq        !! Equality (aborts on a null operand).
        generic :: operator(/=) => date_ne        !! Inequality (aborts on a null operand).
        generic :: operator(<) => date_lt         !! Ordering (aborts on a null operand).
        generic :: operator(<=) => date_le        !! Ordering (aborts on a null operand).
        generic :: operator(>) => date_gt         !! Ordering (aborts on a null operand).
        generic :: operator(>=) => date_ge        !! Ordering (aborts on a null operand).
        procedure, private :: date_diff           !! (date, date) specific of operator(-): whole-day difference.
        procedure, private :: date_sub_days_i32   !! (date, integer(int32)) specific of operator(-).
        procedure, private :: date_sub_days_i64   !! (date, integer(int64)) specific of operator(-).
        procedure, private :: date_add_days_i32   !! (date, integer(int32)) specific of operator(+).
        procedure, private :: date_add_days_i64   !! (date, integer(int64)) specific of operator(+).
        generic :: operator(-) => date_diff, date_sub_days_i32, date_sub_days_i64
        !! Difference or day offset (aborts on a null operand / out-of-range result).
        generic :: operator(+) => date_add_days_i32, date_add_days_i64
        !! Day offset (aborts on a null operand / out-of-range result).
    end type parquet_date