The current date and time in UTC, with utc_offset_min zero.
ERROR_GENERIC when the processor cannot supply its offset from UTC,
rather than silently returning local time labelled as UTC.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(datetime_t), | intent(out) | :: | dt | |||
| type(error_t), | intent(inout), | optional | :: | err |
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| type(datetime_t), | private | :: | local | ||||
| integer(kind=int64), | private | :: | utc_ms | ||||
| integer, | private | :: | values(DATE_AND_TIME_VALUES) |
subroutine now_utc(dt, err) !! The current date and time in UTC, with `utc_offset_min` zero. !! !! `ERROR_GENERIC` when the processor cannot supply its offset from UTC, !! rather than silently returning local time labelled as UTC. type(datetime_t), intent(out) :: dt type(error_t), intent(inout), optional :: err ! Default integer kind, as F2018 16.9.59 requires for this argument; ! this is the one place in PIC where a bare `integer` is correct. integer :: values(DATE_AND_TIME_VALUES) type(datetime_t) :: local integer(int64) :: utc_ms call date_and_time(values=values) if (values(4) == -huge(0)) then call error_raise(err, ERROR_GENERIC, & "pic_clock: the processor does not supply its offset from UTC.") return end if call now_local(local, err) if (present(err)) then if (err%has_error()) return end if utc_ms = unix_time_ms(local) dt = datetime_from_unix_ms(utc_ms) end subroutine now_utc