Date and time functions.
ISO 8601/RFC 3339 is used as the universal date and time format. Date and
time are separated by character T
. The time has microsecond resolution,
a time zone is mandatory. A valid timestamp must contain at least the
full year, and be between 4 and 32 characters long. For example, the
string 1970-01-01T00:00:00.000000+00:00
is a valid DMPACK time stamp.
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
integer, | public, | parameter | :: | TIME_LEN | = | 32 |
Length of ISO 8601 time stamp. |
integer, | public, | parameter | :: | TIME_BEATS_LEN | = | 8 |
Length of beats string. |
integer, | public, | parameter | :: | TIME_HUMAN_LEN | = | 26 |
Length of human-readable time stamp. |
character(len=*), | public, | parameter | :: | TIME_DEFAULT | = | '1970-01-01T00:00:00.000000+00:00' |
Default ISO 8601 time stamp with microseconds. |
Converts Unix epoch to integer or string representation.
Converts the 8-byte calendar time epoch
in UTC to broken-down time
representation. The argument epoch
is the number of seconds
elapsed since the Epoch, 1970-01-01 00:00:00 +0000 (UTC). The
function calls gmtime_r()
internally (SUSv2).
Returns E_SYSTEM
if the system call failed.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=i8), | intent(in) | :: | epoch |
Unix time stamp in seconds (UTC). |
||
integer, | intent(out), | optional | :: | year |
Year part of time stamp. |
|
integer, | intent(out), | optional | :: | month |
Month part of time stamp. |
|
integer, | intent(out), | optional | :: | day |
Day of month part of time stamp. |
|
integer, | intent(out), | optional | :: | hour |
Hour part of time stamp. |
|
integer, | intent(out), | optional | :: | minute |
Minute part of time stamp. |
|
integer, | intent(out), | optional | :: | second |
Second part of time stamp. |
Converts the 8-byte calendar time epoch
in UTC to ISO 8601
representation. The argument epoch
is the number of seconds
elapsed since the Epoch, 1970-01-01 00:00:00 +0000 (UTC). The
function calls gmtime_r()
internally (SUSv2).
Returns E_SYSTEM
if the system call failed.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=i8), | intent(in) | :: | epoch |
Unix time stamp in seconds (UTC). |
||
character(len=TIME_LEN), | intent(out) | :: | time |
ISO 8601 representation. |
Time delta type to store elapsed time.
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
integer, | public | :: | days | = | 0 |
Bygone days. |
|
integer, | public | :: | hours | = | 0 |
Bygone hours. |
|
integer, | public | :: | minutes | = | 0 |
Bygone minutes. |
|
integer, | public | :: | seconds | = | 0 |
Bygone seconds. |
Returns 32-characters long time stamp string in ISO 8601/RFC 3339 of
the form 1970-01-01T00:00:00.000000+00:00
. Optional argument
zone
sets the time zone and has to be of the form [+|-]hh:mm
,
for example, +00:00
or -01:00
.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in), | optional | :: | year |
Year ( |
|
integer, | intent(in), | optional | :: | month |
Month ( |
|
integer, | intent(in), | optional | :: | day |
Day of month ( |
|
integer, | intent(in), | optional | :: | hour |
Hour ( |
|
integer, | intent(in), | optional | :: | minute |
Minute ( |
|
integer, | intent(in), | optional | :: | second |
Second ( |
|
integer, | intent(in), | optional | :: | usecond |
Microsecond ( |
|
character(len=6), | intent(in), | optional | :: | zone |
Timezone ( |
Converts time_delta_type
to string of format
[d days ][h hours ][m mins ][s secs]
.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(time_delta_type), | intent(inout) | :: | time_delta |
Time delta type. |
||
logical, | intent(in), | optional | :: | days |
Write days, |
|
logical, | intent(in), | optional | :: | hours |
Write hours, |
|
logical, | intent(in), | optional | :: | minutes |
Write minutes, |
|
logical, | intent(in), | optional | :: | seconds |
Write seconds, |
Returns the time difference between time1
and time2
as 8-byte
integer seconds
[sec]. The function does not validate the time
stamps. Make sure to only pass valid values. On error, the result
seconds
is huge(0_i8)
.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=TIME_LEN), | intent(in) | :: | time1 |
ISO 8601 time stamp. |
||
character(len=TIME_LEN), | intent(in) | :: | time2 |
ISO 8601 time stamp. |
||
integer(kind=i8), | intent(out) | :: | seconds |
Time delta [sec]. |
Returns .true.
if given time stamp follows the form of ISO 8601. The
time stamp does not have to be complete to be valid, unless strict
is .true.
. Then, argument time
must be 32-characters long.
Otherwise, the minimum length of a time stamp to be valid is 4
characters, the maximum is 32 characters.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | time |
ISO 8601 time stamp to validate. |
||
logical, | intent(in), | optional | :: | strict |
Validate length (must be 32 characters). |
Returns current time in mseconds as 8-byte integer (Unix Epoch). On error, the result is 0.
Returns current date and time as 32-characters long string in ISO
8601/RFC 3339 format (1970-01-01T00:00:00.000000+00:00
), and
microsecond resolution.
Returns current date and time as 31-characters long string in RFC 2822 format.
Strips the microseconds part of the given ISO 8601 time stamp and
returns a 25-characters long string. The function does not validate
the time stamp for performance reasons. Make sure that only a valid
32-characters long ISO 8601 time stamp is passed in time
.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=TIME_LEN), | intent(in) | :: | time |
ISO 8601 time stamp. |
Converts ISO 8601 time stamp time
into
Swatch Internet Time
(.beat time) in the form @1000.00
in beats
. One beat is
equivalent to one decimal minute in the French decimal time (1 min
26.4 sec in Solar time).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=TIME_LEN), | intent(in) | :: | time |
ISO 8601 time stamp. |
||
character(len=TIME_BEATS_LEN), | intent(out) | :: | beats |
Timestamp converted to .beat. |
Returns time stamp as 26-characters long string in human-readable
format. Converts the given ISO 8601 time stamp time
in format
1970-01-01T00:00:00.000000+00:00
to format
1970-01-01 00:00:00 +00:00
. The argument time
is not validated.
Make sure to only pass valid values.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=TIME_LEN), | intent(in) | :: | time |
ISO 8601 time stamp. |
Human-readable time stamp.
Converts 32-characters long ISO 8601/RFC 3339 time stamp to Unix
time stamp (Epoch). The function calls timegm()
internally (not
in POSIX, but available since 4.3BSD), and then removes the time
zone offset. The returned Epoch is always in UTC. The output does
not contain microseconds.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=TIME_LEN), | intent(in) | :: | time |
ISO 8601 time stamp. |
||
integer(kind=i8), | intent(out) | :: | epoch |
Unix time stamp. |
||
integer, | intent(out), | optional | :: | useconds |
Additional microseconds. |
Returns current time zone as five characters long string, for
example, +0000
.
Returns current time zone as six characters long string (ISO format),
for example, +00:00
.
Returns time delta type time_delta
from Unix time stamp in seconds
.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(time_delta_type), | intent(out) | :: | time_delta |
Time delta type. |
||
integer(kind=i8), | intent(in) | :: | seconds |
Unix time stamp (Epoch). |
Returns current date and time values as strings in given dummy arguments.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=4), | intent(out), | optional | :: | year |
Current year ( |
|
character(len=2), | intent(out), | optional | :: | month |
Current month ( |
|
character(len=2), | intent(out), | optional | :: | day |
Current day of month ( |
|
character(len=2), | intent(out), | optional | :: | hour |
Current hour ( |
|
character(len=2), | intent(out), | optional | :: | minute |
Current minute ( |
|
character(len=2), | intent(out), | optional | :: | second |
Current second ( |
|
character(len=6), | intent(out), | optional | :: | usecond |
Current usecond ( |
|
character(len=3), | intent(out), | optional | :: | zone_hour |
Current time zone ( |
|
character(len=2), | intent(out), | optional | :: | zone_minute |
Current time zone ( |
|
character(len=6), | intent(out), | optional | :: | zone |
Current time zone ( |