Date/time intervals, called durations, are modeled in a style quite similar to that of SQL. There are two, effectively disjoint, classes of duration: one with a resolution of months (for example, 3 years, 2 months) and the other with a resolution of microseconds (for example, 50 days, 6 hours, 23 minutes). The first is <year/month-duration> and the second <day/time-duration>.
An important distinction between <day/time-duration> and <year/month-duration> is that a given instance of <day/time-duration> is always a fixed unit of a fixed length, whereas a <year/month-duration> follows the vagaries of the calendar. So if you have a <date> that represents, for example, the 5th of some month, adding a <year/month-duration> of 1 month to that will always take you to the 5th of the following month, whether that is an interval of 28, 29, 30, or 31 days.
Sealed abstract instantiable class
<number>, and it has two subclasses, described below.
Sealed class
<duration>.
Sealed class
<duration>.
The following functions and methods are available for creating durations, and decoding them into their constituent integer parts.
encode-year/month-durationFunction
encode-year/month-duration years months => duration
<year/month-duration>.
Function
encode-day/time-duration days hours minutes seconds microseconds => duration
<day/time-duration>.
Sealed generic function
decode-duration duration => #rest components
<duration> into its constituent parts. There are methods for this generic function that specialize on <year/month-duration> and <day/time-duration> respectively, as described below.
Sealed method
decode-duration duration => years months
<year/month-duration> into its constituent parts.
Sealed method
decode-duration duration => days hours minutes seconds microseconds
<day/time-duration> into its constituent parts.