| Did you know ... | Search Documentation: |
| Pack logtalk -- logtalk-3.99.0/docs/handbook/_sources/libraries/dates.rst.txt |
.. _library_dates:
dates
The date object implements some useful calendar date predicates.
It also provides portable predicates for date-time handling, including:
The duration predicates accept two duration representations:
duration(Days, Hours, Minutes, Seconds) â a fixed-length duration
converted to secondsduration(Years, Months, Days, Hours, Minutes, Seconds) â a
calendar-aware period where the year and month delta is applied first
using calendar arithmetic, clamping the day to the last valid day of
the resulting month when necessary (e.g. adding one month to January
31 gives February 28 or 29 depending on the year), with the remaining
day and time delta applied via fixed-length arithmetic. The
duration_between/3 predicate returns this form when called with a
6-arity skeleton such as duration(Yr, Mo, Da, Hr, Mi, Se).
Date-time values are represented using the date_time/6 compound term:
date_time(Year, Month, Day, Hours, Minutes, Seconds)
The format_date_time/4 predicate currently supports the named
formats rfc3339, iso8601, atom, rfc2822, rfc5322,
rss, http_date, rfc1123, unix_date, common_log,
date_short, date_medium, date_long, date_full,
time_short, time_medium, time_long, time_full,
date_time_short, date_time_medium, date_time_long, and
date_time_full.
The explicit offset argument is given in seconds. Formats that include
numeric offsets require offsets representable in whole minutes. The
http_date and rfc1123 formats always normalize the output to
GMT.
The style presets are currently English-only presentation formats:
date_short -> 2026-04-08date_medium -> 8 Apr 2026date_long -> April 8, 2026date_full -> Tuesday, April 8, 2026time_short -> 13:45time_medium -> 13:45:30time_long -> 13:45:30 +01:00time_full -> 1:45:30 PM +01:00date_time_short -> 2026-04-08 13:45date_time_medium -> 8 Apr 2026 13:45:30date_time_long -> April 8, 2026 1:45:30 PM +01:00date_time_full -> Tuesday, April 8, 2026 1:45:30 PM +01:00
The time object implements some useful time predicates.
Please note that the functionality of these objects depends on the chosen Prolog support for accessing the operating system time and date.
Open the `../../apis/library_index.html#dates <../../apis/library_index.html#dates>`__ link in a web browser.
To load all entities in this library, load the loader.lgt utility
file:
::
| ?- logtalk_load(dates(loader)).
To test this library predicates, load the tester.lgt file:
::
| ?- logtalk_load(dates(tester)).