Did you know ... Search Documentation:
Packs (add-ons) for SWI-Prolog

Package "date_time"

Title:Logical arithmetic on dates and times
Rating:Not rated. Create the first rating!
Latest version:0.1.0
SHA1 sum:b0d21e8e1be1a1635d4016ad5ebe9dadbf5aabd6
Author:Falco Nogatz <fnogatz@gmail.com>
Maintainer:Falco Nogatz <fnogatz@gmail.com>
Packager:Falco Nogatz <fnogatz@gmail.com>
Home page:https://github.com/fnogatz/date_time
Download URL:https://github.com/fnogatz/date_time/releases/*.zip

Reviews

No reviews. Create the first review!.

Details by download location

VersionSHA1#DownloadsURL
0.1.0b0d21e8e1be1a1635d4016ad5ebe9dadbf5aabd62https://github.com/fnogatz/date_time/archive/v0.1.0.zip

Date Time Library

The Date Time Library contains predicates that perform logical arithmetic on dates and times. It is an adapted version of the original date_time library that is part of Amzi! Core Components by Amzi! inc., to be compatible with SWI-Prolog's module system.

The library uses three structures: date/3, time/3 and datetime/6. Predicates are provided for dealing with each. The structure arguments are:

date(Year,Month,Day)
time(Hour,Minutes,Seconds)
datetime(Year,Month,Day,Hour,Minutes,Seconds)

The various predicates try to do the correct thing when overflowing the various quantities, like taking into account the number of days in February when adding, say, 15 days to Feb 20th. The result will be a different day in March depending on whether the year is a leap year or not.

The predicates also recognize the last day of each month as a special case. So if you add a month to a date which is the last day of a month, you get the last day of the next month.

The structures represent absolute dates and times. Relative date/time quantities are represented by structures for each unit, with one argument which is the value. These structures are: years/1, months/1, weeks/1, days/1, hours/1, mins/1, and secs/1.

Each is defined as a postfix operator as well. So you can ask for example:

?- date_add(date(2002,1,15), 2 weeks, X).
X = date(2002,1,29)
yes

The library includes predicates to parse and create date and time strings.

To use the library, either consult or load the date_time file, or include it in your Prolog project. Then import it. For example, from the listener:

?- load(date_time).
yes
?- import(date_time).
yes

Contents of pack "date_time"

Pack contains 7 files holding a total of 35.5K bytes.