datetime_t Derived Type

type, public :: datetime_t

A broken-down calendar date and time.

utc_offset_min is the number of minutes local time is ahead of UTC, so it is negative in the Americas. A value of zero means the instant is expressed in UTC – but only when utc_offset_known is true.

utc_offset_known exists because zero is a real offset. A processor that cannot tell you its offset from UTC leaves the field at zero, and without a separate flag that is indistinguishable from being on the Greenwich meridian: the time would format as ...Z and convert as though it were UTC, silently wrong by the size of the offset.


Components

Type Visibility Attributes Name Initial
integer(kind=default_int), public :: day = 1
integer(kind=default_int), public :: hour = 0
integer(kind=default_int), public :: millisecond = 0
integer(kind=default_int), public :: minute = 0
integer(kind=default_int), public :: month = 1
integer(kind=default_int), public :: second = 0
logical, public :: utc_offset_known = .true.

False when the processor could not supply an offset from UTC. The date and time are still valid; only their relation to UTC is not.

integer(kind=default_int), public :: utc_offset_min = 0
integer(kind=default_int), public :: year = 1970

Source Code

   type :: datetime_t
      !! A broken-down calendar date and time.
      !!
      !! `utc_offset_min` is the number of minutes local time is **ahead** of
      !! UTC, so it is negative in the Americas. A value of zero means the
      !! instant is expressed in UTC -- but only when `utc_offset_known` is
      !! true.
      !!
      !! `utc_offset_known` exists because zero is a real offset. A processor
      !! that cannot tell you its offset from UTC leaves the field at zero,
      !! and without a separate flag that is indistinguishable from being on
      !! the Greenwich meridian: the time would format as `...Z` and convert
      !! as though it were UTC, silently wrong by the size of the offset.
      integer(default_int) :: year = 1970
      integer(default_int) :: month = 1
      integer(default_int) :: day = 1
      integer(default_int) :: hour = 0
      integer(default_int) :: minute = 0
      integer(default_int) :: second = 0
      integer(default_int) :: millisecond = 0
      integer(default_int) :: utc_offset_min = 0
      logical :: utc_offset_known = .true.
         !! False when the processor could not supply an offset from UTC. The
         !! date and time are still valid; only their relation to UTC is not.
   end type datetime_t