Module time
:- use_module(library(time)).
This library provides predicates for reasoning about time.
current_time(-T)
Yields the current system time T in an opaque form, called a time stamp. Use format_time//2
to describe strings that contain attributes of the time stamp.
format_time(FormatString, TimeStamp)//
The nonterminal format_time//2 describes a list of characters that are formatted according to a format string. Usage:
phrase(format_time(FormatString, TimeStamp), Cs)
TimeStamp represents a moment in time in an opaque form, as for example obtained by current_time/1
.
FormatString is a list of characters that are interpreted literally, except for the following specifiers (and possibly more in the future):
%Y | year of the time stamp. Example: 2020. |
%m | month number (01-12), zero-padded to 2 digits |
%d | day number (01-31), zero-padded to 2 digits |
%H | hour number (00-24), zero-padded to 2 digits |
%M | minute number (00-59), zero-padded to 2 digits |
%S | second number (00-60), zero-padded to 2 digits |
%b | abbreviated month name, always 3 letters |
%a | abbreviated weekday name, always 3 letters |
%A | full weekday name |
%j | day of the year (001-366), zero-padded to 3 digits |
%% | the literal % |
Example:
?- current_time(T), phrase(format_time("%d.%m.%Y (%H:%M:%S)", T), Cs).
T = [...], Cs = "11.06.2020 (00:24:32)".
max_sleep_time(T)
The maximum admissible time span for sleep/1
.
sleep(S)
Sleeps for S seconds (a floating point number or integer).
statistics(?Keyword, ?List)
Preliminary support for statistics/2, yielding timing information. The only supported Keyword
is runtime
. The first element of List
is the CPU time in milliseconds, the second element is currently not supported.
time(Goal)
Reports the execution time of Goal.