Common Lisp Package: TIME-INTERVAL

README:

time-interval

Cyrus Harmon

time-interval is a common lisp library for flexibly encoding time intervals. It relies heavily on the local-time library for the representation of particular points in time, or as local-time calls them, timestamps.

The primary motivation for time-interval is to be able to represent periods of time such as "6 months from July 1, 2008". The idea here isn't to represent the start and dates (or times) explicitly, but rather to flexibly represent the interval. The difficulty arises from the fact that a length of time such as "6 months" can't be uniquely represented as a number of days, hours, minutes, etc... Depending on what the starting point is, the number of days (hours, etc...) in a 6-month interval will change. Therefore, we need a way of representing the time intervals and for computing a new exact time given a starting time and a time interval.

Required Libraries:

cl-ppcre, local-time

Classes:

time-interval

The time-interval class is used for representing a given interval of time, such as 6 months, 2 days, 4 hours and 3 seconds. Each of the components can independenly be positive or negative, so we can have, for instance, an interval that represents 1 hour less than two days, by doing:

(make-instance 'time-interval :hours -1 :days 2) 

or:

(time-interval :hours -1 :days 2) 

FUNCTION

Public

Undocumented

COPY-TIME-INTERVAL (ORIG)

MAKE-TIMESTAMP* (&KEY YEAR MONTH DAY HOUR MINUTE SECOND NANOSECOND)

NEGATE-TIME-INTERVAL (ORIG)

PARSE-TIME-INTERVAL-STRING (STRING)

TIME-INTERVAL (&REST ARGS)

Private

Undocumented

TIMESTAMP-ADD-INTERVAL (TIME INTERVAL)

MACRO

Private

Undocumented

OR-ZERO (VALUE)

GENERIC-FUNCTION

Public

Undocumented

T+ (TIME-OR-INTERVAL-1 TIME-OR-INTERVAL-2)

T- (TIME-OR-INTERVAL-1 TIME-OR-INTERVAL-2)

SLOT-ACCESSOR

Private

Undocumented

INTERVAL-DAYS (OBJECT)

SETFINTERVAL-DAYS (NEW-VALUE OBJECT)

INTERVAL-HOURS (OBJECT)

SETFINTERVAL-HOURS (NEW-VALUE OBJECT)

INTERVAL-MINUTES (OBJECT)

SETFINTERVAL-MINUTES (NEW-VALUE OBJECT)

INTERVAL-MONTHS (OBJECT)

SETFINTERVAL-MONTHS (NEW-VALUE OBJECT)

INTERVAL-NANOSECONDS (OBJECT)

SETFINTERVAL-NANOSECONDS (NEW-VALUE OBJECT)

INTERVAL-SECONDS (OBJECT)

SETFINTERVAL-SECONDS (NEW-VALUE OBJECT)

INTERVAL-WEEKS (OBJECT)

SETFINTERVAL-WEEKS (NEW-VALUE OBJECT)

INTERVAL-YEARS (OBJECT)

SETFINTERVAL-YEARS (NEW-VALUE OBJECT)

VARIABLE

Private

Undocumented

*UNIT-HASH*

CLASS

Public

Undocumented

TIME-INTERVAL (&REST ARGS)