protocol

datep

Date protocol.

Availability:
logtalk_load(dates(loader))
Author: Paulo Moura
Version: 1:2:0
Date: 2026-02-25
Compilation flags:
static
Dependencies:
(none)
Remarks:
(none)
Inherited public predicates:
(none)

Public predicates

today/3

Returns current date.

Compilation flags:
static
Template:
today(Year,Month,Day)
Mode and number of proofs:
today(-integer,-integer,-integer) - one

leap_year/1

True if the argument is a leap year.

Compilation flags:
static
Template:
leap_year(Year)
Mode and number of proofs:
leap_year(+integer) - zero_or_one

name_of_day/3

Name and short name of day.

Compilation flags:
static
Template:
name_of_day(Index,Name,Short)
Mode and number of proofs:
name_of_day(?integer,?atom,?atom) - zero_or_more

name_of_month/3

Name and short name of month.

Compilation flags:
static
Template:
name_of_month(Index,Name,Short)
Mode and number of proofs:
name_of_month(?integer,?atom,?atom) - zero_or_more

days_in_month/3

Number of days in a month.

Compilation flags:
static
Template:
days_in_month(Month,Year,Days)
Mode and number of proofs:
days_in_month(?integer,+integer,?integer) - zero_or_more

valid/3

True if the arguments represent a valid date.

Compilation flags:
static
Template:
valid(Year,Month,Day)
Mode and number of proofs:
valid(@integer,@integer,@integer) - zero_or_one

date_time_to_unix/2

Converts a UTC date-time term date_time(Year,Month,Day,Hours,Minutes,Seconds) to Unix epoch seconds.

Compilation flags:
static
Template:
date_time_to_unix(DateTime,UnixTime)
Mode and number of proofs:
date_time_to_unix(+compound,-integer) - zero_or_one

unix_to_date_time/2

Converts Unix epoch seconds to a UTC date-time term date_time(Year,Month,Day,Hours,Minutes,Seconds).

Compilation flags:
static
Template:
unix_to_date_time(UnixTime,DateTime)
Mode and number of proofs:
unix_to_date_time(+integer,-compound) - one

add_duration/3

Adds a duration to a datetime. Duration can be integer seconds or duration(Days,Hours,Minutes,Seconds).

Compilation flags:
static
Template:
add_duration(DateTime,Duration,ResultDateTime)
Mode and number of proofs:
add_duration(+compound,+nonvar,-compound) - zero_or_one

subtract_duration/3

Subtracts a duration from a datetime. Duration can be integer seconds or duration(Days,Hours,Minutes,Seconds).

Compilation flags:
static
Template:
subtract_duration(DateTime,Duration,ResultDateTime)
Mode and number of proofs:
subtract_duration(+compound,+nonvar,-compound) - zero_or_one

duration_between/3

Computes the difference between two datetimes as integer seconds or as duration(Days,Hours,Minutes,Seconds).

Compilation flags:
static
Template:
duration_between(StartDateTime,EndDateTime,Duration)
Mode and number of proofs:
duration_between(+compound,+compound,?term) - zero_or_one

utc_to_local/3

Converts a UTC datetime to a local datetime using an explicit timezone offset atom (Z or ±HH:MM).

Compilation flags:
static
Template:
utc_to_local(UTCDateTime,Offset,LocalDateTime)
Mode and number of proofs:
utc_to_local(+compound,+atom,-compound) - zero_or_one

local_to_utc/3

Converts a local datetime to UTC using an explicit timezone offset atom (Z or ±HH:MM).

Compilation flags:
static
Template:
local_to_utc(LocalDateTime,Offset,UTCDateTime)
Mode and number of proofs:
local_to_utc(+compound,+atom,-compound) - zero_or_one

day_of_year/2

Computes the day of year (1-366) for a date(Year,Month,Day) or date_time(...) term.

Compilation flags:
static
Template:
day_of_year(DateLike,DayOfYear)
Mode and number of proofs:
day_of_year(+compound,?integer) - zero_or_one

week_of_year_iso/2

Computes ISO week for a date(Year,Month,Day) or date_time(...) term as week(Week,Year).

Compilation flags:
static
Template:
week_of_year_iso(DateLike,ISOWeek)
Mode and number of proofs:
week_of_year_iso(+compound,?compound) - zero_or_one

weekday/2

Computes ISO weekday number (Monday=1, …, Sunday=7) for a date(Year,Month,Day) or date_time(...) term.

Compilation flags:
static
Template:
weekday(DateLike,Weekday)
Mode and number of proofs:
weekday(+compound,?integer) - zero_or_one

normalize_date_time/2

Normalizes a datetime term by carrying overflows/underflows in date and time fields.

Compilation flags:
static
Template:
normalize_date_time(DateTime,NormalizedDateTime)
Mode and number of proofs:
normalize_date_time(+compound,-compound) - one

valid_date_time/1

True iff a datetime term is valid in strict mode.

Compilation flags:
static
Template:
valid_date_time(DateTime)
Mode and number of proofs:
valid_date_time(@compound) - zero_or_one

valid_date_time/2

Validates a datetime term in strict or relaxed mode.

Compilation flags:
static
Template:
valid_date_time(DateTime,Mode)
Mode and number of proofs:
valid_date_time(@compound,+atom) - zero_or_one

Protected predicates

(none)

Private predicates

(none)

Operators

(none)

See also

date, timep