TL;DR: The predicate datime/2 (offered by SICStus Prolog and SWI-Prolog) relates UNIX time to a record containing year, month, day, hour, minute, and second.
For some corner cases I got weird answers which made me wonder: Which error(s) should ISO-compliant Prolog systems raise in these cases?
First, here's the datime/2 documentation—part of the SICStus Prolog Manual:
now(-When)Unifies the current date and time as a UNIX timestamp withWhen.
datime(-Datime)UnifiesDatimewith the current date and time as adatime/6record of the formdatime(Year,Month,Day,Hour,Min,Sec). All fields are integers.
datime(+When,-Datime)datime(-When,+Datime)Convert a time stamp, as obtained bynow/1, to adatime/6record. Can be used in both directions.
So here is some spurious SICStus Prolog 4.6.0 output:
| ?- use_module(library(system)).
yes
| ?- datime(X,Y).
no % expected: result | error
| ?- datime(-67768200000000000,X).
no % expected: result | error
| ?- datime(X,datime(19700000000000,1,1,1,0,0)).
X = -32029950380687608 ? ; % expected: X >= 0
no
And here come some weird "answers" given by SWI-Prolog 8.2.0:
?- use_module(library(dialect/sicstus/system)).
true.
?- datime(X,datime(1970,1,1,1,0,0)).
ERROR: Arguments are not sufficiently instantiated
% expected: X = 0
?- datime(10000000000000000000000000,X).
X = datime(1901, 1461302465, 32753, 9, 35, 13).
?- datime(1000000000000000000000000000,X).
X = datime(1901, 1461302465, 32753, 9, 35, 13).
?- datime(100000000000000000000000000000,X).
X = datime(1901, 1461302465, 32753, 9, 35, 13).
% expected: different answers for different queries
So: Which error(s) should a ISO-compliant Prolog system raise in these cases?