Skip to content

foresight_time ​

foresight_time, gnuplot's time values: seconds since 1970-01-01 00:00 UTC, written and read as gnuplot 6.0's strftime and strptime do.

Dates are proleptic Gregorian, without leap seconds or time zones, as gnuplot's. The conversions are gnuplot's own (gstrftime, gstrptime), not C's: %p writes am/pm, %.3S writes fractional seconds, %tH, %tM, %tS write and read elapsed times; a conversion gnuplot does not know writes nothing.

Source: src/lib/foresight_time.F90

Dependencies

Contents ​

Variables ​

NameTypeAttributesDescription
DAY_SECreal(kind=R8P)parameterSeconds of a day.
WEEK_SECreal(kind=R8P)parameterSeconds of a week.
YEAR_SECreal(kind=R8P)parameterSeconds of a mean year (gnuplot's).
MON_SECreal(kind=R8P)parameterSeconds of a mean month (gnuplot's).
DAY_NAMEScharacter(len=9)parameterWeekday names.
MONTH_NAMEScharacter(len=9)parameterMonth names.

Subroutines ​

civil_from_days ​

The date of days since 1970-01-01 (H. Hinnant's algorithm).

Attributes: pure

fortran
subroutine civil_from_days(days, y, m, d)

Arguments

NameTypeIntentAttributesDescription
daysinteger(kind=I8P)inDays since the epoch.
yinteger(kind=I8P)outYear.
minteger(kind=I8P)outMonth, 1 for January.
dinteger(kind=I8P)outDay of the month, from 1.

Call graph

time_parts ​

The broken-down time of t [s since the epoch]: yday the day of the year from 1, wday the weekday from 0 (Sunday); second whole, fraction the rest of it (in [0, 1)).

Attributes: pure

fortran
subroutine time_parts(t, year, month, day, hour, minute, second, fraction, yday, wday)

Arguments

NameTypeIntentAttributesDescription
treal(kind=R8P)inTime [s].
yearinteger(kind=I8P)outYear.
monthinteger(kind=I8P)outMonth, 1 for January.
dayinteger(kind=I8P)outDay of the month, from 1.
hourinteger(kind=I8P)outHour.
minuteinteger(kind=I8P)outMinute.
secondinteger(kind=I8P)outSecond.
fractionreal(kind=R8P)outFraction of the second.
ydayinteger(kind=I8P)outDay of the year, from 1.
wdayinteger(kind=I8P)outWeekday, 0 Sunday.

Call graph

strptime ​

text read with the time format, as gnuplot's strptime: %d %m %H %M (up to 2 digits), %y (2 digits, 69 to 99 the 1900s, else the 2000s), %Y (up to 4), %j (up to 3), %S (seconds with a fraction), %s (seconds since the epoch), %b %B (month names or their 3 first letters), %a %A (weekday names, skipped), %p (pm adds 12 hours), %tH %tM %tS (elapsed hours, minutes, seconds, signed, the last with a fraction), %z (a zone offset, Z or [+-]hh[:]mm, taken off), %Z (a zone name, skipped); a blank matches any run of blanks, any other character itself. Fields not given are those of 1970-01-01 00:00:00, also those after the end of the text (gnuplot reads "1/6/93" with "%d/%m/%y %H%M"). ok false (t NaN) if text does not match. Sign of the offset. Hours. Minutes. Read status.

Attributes: pure

fortran
subroutine strptime(format, text, t, ok)

Arguments

NameTypeIntentAttributesDescription
formatcharacter(len=*)inTime format.
textcharacter(len=*)inText.
treal(kind=R8P)outTime [s].
oklogicaloutText matched.

Call graph

Functions ​

days_from_civil ​

Days from 1970-01-01 to the date y-m-d (H. Hinnant's algorithm; m and d may overflow their ranges).

Attributes: pure

Returns: integer(kind=I8P)

fortran
function days_from_civil(y, m, d) result(days)

Arguments

NameTypeIntentAttributesDescription
yinteger(kind=I8P)inYear.
minteger(kind=I8P)inMonth, 1 for January.
dinteger(kind=I8P)inDay of the month, from 1.

Call graph

civil_time ​

Seconds since the epoch of a date and time (fields may overflow their ranges, as mktime's).

Attributes: pure

Returns: real(kind=R8P)

fortran
function civil_time(year, month, day, hour, minute, second) result(t)

Arguments

NameTypeIntentAttributesDescription
yearinteger(kind=I8P)inYear.
monthinteger(kind=I8P)inMonth, 1 for January.
dayinteger(kind=I8P)inDay of the month, from 1.
hourinteger(kind=I8P)inHour.
minuteinteger(kind=I8P)inMinute.
secondreal(kind=R8P)inSecond, with its fraction.

Call graph

now_seconds ​

The time now as seconds since the epoch of the local wall clock (gnuplot set timestamp), or the environment's SOURCE_DATE_EPOCH when set (reproducible output, beyond gnuplot).

Returns: real(kind=R8P)

fortran
function now_seconds() result(t)

Call graph

strftime ​

t [s since the epoch] written with the time format, as gnuplot's strftime: %a %A %b %B %h names, %d %m %y %Y %j %H %I %M %S numbers (zero padded), %k %l hours (blank padded), %p am/pm, %s the seconds since the epoch, %w the weekday number, %U %W week numbers, %D (%m/%d/%y), %F (%Y-%m-%d), %T (%H:%M:%S), %R (%H:%M), %r (%I:%M:%S %p), %.NS the seconds with N decimals, %tH %tM %tS the elapsed hours, minutes, seconds (the largest unit present unbounded), %%; others write nothing.

Attributes: pure

Returns: character(len=:)

fortran
function strftime(format, t) result(text)

Arguments

NameTypeIntentAttributesDescription
formatcharacter(len=*)inTime format.
treal(kind=R8P)inTime [s].

Call graph

time_format_check ​

Empty if format is a time format: text whose % conversions are among those strftime knows (a gnuplot set format x "%H:%M" on a time axis); else the problem.

Attributes: pure

Returns: character(len=:)

fortran
function time_format_check(format) result(message)

Arguments

NameTypeIntentAttributesDescription
formatcharacter(len=*)inFormat.

Call graph

time_justify ​

t moved to a whole time unit of the tick level (0 seconds, 1 minutes, 2 hours, 3 days, 4 weeks, 5 months, 6 years), as gnuplot's time_tic_just: days and longer at 0 AM, minutes and hours rounded up past 55, months to the 1st (the next month past the 25th).

Attributes: pure

Returns: real(kind=R8P)

fortran
function time_justify(level, t) result(justified)

Arguments

NameTypeIntentAttributesDescription
levelinteger(kind=I4P)inTick level.
treal(kind=R8P)inTime [s].

Call graph

padded ​

n in decimal, padded on the left with pad to width characters (a minus sign first).

Attributes: pure

Returns: character(len=:)

fortran
function padded(n, width, pad) result(text)

Arguments

NameTypeIntentAttributesDescription
ninteger(kind=I8P)inNumber.
widthinteger(kind=I4P)inLeast width.
padcharacter(len=1)inPadding character.

Call graph

decimals ​

. then prec decimals of fraction (in [0, 1)), rounded and never carried (at most 0.99...), as gnuplot 6.0's %.NS (time.c: floor(0.5 + 10**prec * fraction), capped).

Attributes: pure

Returns: character(len=:)

fortran
function decimals(fraction, prec) result(text)

Arguments

NameTypeIntentAttributesDescription
fractionreal(kind=R8P)inFraction.
precinteger(kind=I4P)inDecimals.

Call graph

lower ​

text in lower case.

Attributes: pure

Returns: character(len=len)

fortran
function lower(text) result(low)

Arguments

NameTypeIntentAttributesDescription
textcharacter(len=*)inText.

Call graph

Released under the GPL v3, BSD 2-Clause, BSD 3-Clause or MIT License.