library(date)

library(date) is a time-stamp package.

The parameter ranges are

Year year-1900 (e.g. 1987 -> 87)
Month 0..11 (e.g. January -> 0, September -> 8)
Day 1..31 (e.g. 27 -> 27)
Hour 0..23 (e.g. midnight -> 0, noon -> 12)
Minute 0..59
Second 0..59

These parameter ranges are compatible with the library function localtime(3). Note that the range for months is not what you might expect.

The predicates provided are:

For example,

     | ?- date(X), portray_date(X).
     11-Jan-90
     X = date(90,0,11)
     

Note that if you want both the current date and time, you should call either datime/1 or date_and_time/2. It is an error to obtain the date and time in separate calls, because midnight could intervene and put you nearly 24 hours out.

Dates and datimes are also returned by directory_property/3 and file_property/3 (see library(directory)). All these records can be compared using term comparison.

The predicates time_stamp/[2,3] provide a way of creating a time-stamp atom using a special kind of format string. For example,

     | ?- time_stamp('%W, %d %M %y',Date).
     
     Date = 'Thursday, 11 January 1990'
     

The details of the format strings are explained in a comment in the sources. Please note that, in the interests of internationalization, time_stamp/[2,3] are likely to be superseded in a future release by something based on the ANSI C operation strftime(3). The other predicates in this package will not change at that time.