Class date is a wrapper around Unix's notion of time. It is intended to communicate over creation, last-modification dates, etc. Dates might also be useful for agenda systems and systems that represent some kind of database. For example, this manual tool uses date objects to keep track of the last-modification time of cards.
Unix time is measured in seconds from the Unix epoch: Jan 1, 1970. Therefore, the granularity of a date object is a second. The first date that can be represented is Jan 1, 1970 and the latest date somewhere in the year 2105 (2 to-the-power 32 - 1 seconds from the epoch).
The most important methods are:
<-print_name
and date<-string
which returns a textual representation of the date
<-convert
Convert a textual representation into a date
object.
->current
Update date object to
reflect the current time.
->before, date->after, date->equal
Comparison of dates
<-compare
Comparison of dates compatible with chain->sort.
second.
Please note that larger units are omitted due to their unclear
semantics. Units are converted to seconds. Given that the fields are in
local time, creating a time from fields, date->advance
and get the fields may yield strange results. For example:
?- new(D, date(0, 0, 0, 30, 10, 2005)),
send(D, advance, 1, day),
get(D, string, string(Date))
Date = 'Sun Oct 30 23:00:00 2005'
See also date->month, etc.
->before
and date->equal.->equal
and date->after.get_date()
library and convert various commonly used representations of a date.
Unfortunately this library is undocumented ...->before, date->after
and date<-difference.?- new(D, date(0, 35, 14)).
Represents 14.35h today.
See date->set
for details and limitations.
.e. the number of seconds elapsed since the
epoch, Jan 1, 1970.
This value is passed as a float to avoid the limited range supported by the XPCE int type.
Inherits description from: date<-posix_value
->initialise
if arguments are provided.
It uses the mktime() function which appears to have
different behaviour on different systems on timestamps before the epoch
at Jan. 1, 1970 UTC. On some systems it returns negative values, while
on others it returns the error code -1. Note that even on systems with
negative values the last second before the epoch cannot be represented.
An error is returned if mktime() returns -1.
->sort.
The following example sorts a chain of file
objects according to their last modification time:
send(Files, sort,
?(@arg1?time, compare, @arg2?time))
.y
file converting many commonly used textual representations of date/time.
Before using the getdate.y library it
tries to convert the XML-Schema defined dateTime representation. See
also
date<-string, date<-rfc_string
and date<-xml_string.
Inherits description from: date->convert
to defaults to the
epoch. units defaults to seconds. Note that the result is returned as a
PCE integer and the maximum value of a PCE integer is not sufficient to
represent all time differences in second units. An error (int_range) is
generated on overflow.
See also date->before, date->equal
and date->after.
<-string.
The methods date<-print_name
and date<-convert
are used by class text_item
to represent and modify objects.
<-string
in RFC compatible format. See also date<-xml_string.ctime().
It's format is:
_Mon Sep 14 17:23:18 1992_
See also date<-rfc_string
and date<-xml_string
for conversion to other popular representations.
Bugs: There is no way to manipulate the printed representations of a date apart from redefining this method from scratch.
<-string
in the XML-Schema defined dateTime format. The time is always
represented in UTZ (ending with a Z). See also
date<-rfc_string, date<-string
and date<-convert.
This format is defined as CCYY-MM-DDThh:mm:ss[Z|+-hh:mm].
See the XML schema definition for details.