Did you know ... Search Documentation:
Pack prolog_library_collection -- prolog/date_time.pl
PublicShow source

Support predicates for dealing with date/time representations.

Prolog uses multiple representations for date/time values. This module converts all these representations into one that is consistent with the XSD 7-property model.

Prolog uses the following date/time representations, indicated with `SwiDateTime':

We use the following date/time representation, indicated with `RdfDateTime':

  • dt/7

The SWI standard library `sgml' uses the following date/time representation, indicated with `XsdDateTime':

The purpose of this module is to allow the programmer to write all predicates that use date/time representations to only work with dt/7. This is a huge date/time-saver!

 cpu_time(:Goal_0, -Delta:double) is det
 date_time_to_dt(+SwiDateTime:compound, -RdfDateTime:compound) is det
Converts the three Prolog date/time representations to the one XSD-inspired 7-property model representation (type dt).

Prolog uses the following three date/time representations (type date_time):

  • date(Y,Mo,D)
  • date(Y,Mo,D,H,Mi,S,Off,TZ,DST)
  • time(H,Mi,S)

The one dt representation:

  • dt(Y,Mo,D,H,Mi,S,Off)

Apart from a difference in compound structure there are also two differences in value semantics:

  1. In Prolog S represents the seconds as a floating point number between 0.0 and 60.0. In XSD S represents the seconds as a decimal number greater than or equal to 0 and less than 60.
  2. In Prolog Off represents the offset relative to UTC in seconds as an integer, where positive values are west of Greenwich. In XSD Off represents the offset relative to UTC in minutes as an integer between -840 and 840 inclusive.
 dt_to_date_time(+RdfDateTime:compound, -SwiDateTime:compound) is det
Conversion from the XSD-inspired 7-property model to the three Prolog date/time compound term representations.
 dt_to_timestamp(+RdfDateTime:compound, -Timestamp:float) is det
 is_dt(@Term) is semidet
 is_date_time(@Term) is semidet
 timestamp_to_dt(+Timestamp:float, -RdfDateTime:compound) is det
 date_time_masks(+Masks:list(atom), +SwiDateTime1:compound, -SwiDateTime2:compound) is det
Apply an arbitrary number of date/time masks.
See also
- date_time_mask/3
 now(-RdfDateTime:compound) is det
Return the current date/time as a dt-typed compound term.
 number_of_days_in_month_of_year(?Year:integer, ?Month:between(1,12), ?MaxDay:between(28,31)) is nondet
The number of days in month of year is:
  • 31 if month is 1, 3, 5, 7, 8, 10, or 12;
  • 30 if month is 4, 6, 9, or 11;
  • 29 if month is 2 and year is a number divisible by 400, or if year is a number divisible by 4 but not by 100;
  • 28 otherwise.
 date_time_label(+SwiDateTime:compound, -Label:string) is det
 date_time_label(+SwiDateTime:compound, -Label:string, +Options:options) is det
 dt_label(+RdfDateTime:compound, -Label:string) is det
 dt_label(+RdfDateTime:compound, -Label:string, +Options:options) is det
 generate_as_digits(+N:nonneg, +NumberOfDigits:nonneg)// is det
 generate_as_digits(+N:nonneg, +Base:positive_integer, +NumberOfDigits:nonneg)// is det
Generate the non-negative integer N using exactly NumberOfDigits digits, using `0' as padding if needed.

Undocumented predicates

The following predicates are exported, but not or incorrectly documented.

 date_time_label(Arg1, Arg2, Arg3)
 dt_label(Arg1, Arg2, Arg3)
 generate_as_digits(Arg1, Arg2, Arg3, Arg4, Arg5)