You are looking at historical revision 41242 of this page. It may differ significantly from its current revision.

srfi-19

Time Data Types and Procedures

  1. srfi-19
  2. Documentation
    1. Core Procedures
      1. SRFI-19 Document Changes
        1. make-date
        2. read-leap-second-table
        3. leap-year?
      2. SRFI-18 Time
        1. time->srfi-18-time
        2. srfi-18-time->time
      3. Time Conversion
        1. time-hash
        2. time-copy
        3. seconds->time
        4. seconds->date
        5. time->nanoseconds
        6. nanoseconds->time
        7. nanoseconds->seconds
        8. time->milliseconds
        9. milliseconds->time
        10. milliseconds->seconds
        11. time->date
        12. time->julian-day
        13. time->modified-julian-day
      4. Time Arithmetic
        1. make-duration
        2. one-second-duration
        3. one-nanosecond-duration
        4. zero-time
        5. TIME-FINE-GRAIN
        6. divide-duration
        7. divide-duration!
        8. multiply-duration
        9. multiply-duration!
        10. time-negative?
        11. time-positve?
        12. time-zero?
        13. time-abs
        14. time-abs!
        15. time-negate
        16. time-negate!
      5. Time Comparison
        1. time-compare
        2. time-max
        3. time-min
      6. Dates
        1. default-date-clock-type
        2. date-copy
        3. date->seconds
        4. date->time
        5. date-zone-name
        6. date-dst?
      7. Date Arithmetic
        1. date-difference
        2. date-add-duration
        3. date-subtract-duration
        4. date-adjust
        5. date-adjust*
      8. Date Comparison
        1. date-compare
        2. date-hash
        3. date=?
        4. date>?
        5. date<?
        6. date>=?
        7. date<=?
      9. Timezone
        1. local-timezone-locale
        2. utc-timezone-locale
        3. timezone-locale-name
        4. timezone-locale-offset
        5. timezone-locale-dst?
    2. Input/Output Procedures
      1. DATE->STRING conversion specifiers
        1. format-date
        2. scan-date
        3. string->date
        4. date->string
    3. Date/Time Literals
      1. Usage
        1. date-literal-form
        2. time-literal-form
        3. read-date-literal
        4. write-date-literal
    4. Time Period
      1. Usage
        1. make-time-period
        2. time-period-copy
        3. time-period-begin
        4. time-period-end
        5. time-period-last
        6. time-period-type
        7. time-period?
        8. time-period-length
        9. time-period-hash
        10. time-period-compare
        11. time-period=?
        12. time-period<?
        13. time-period>?
        14. time-period<=?
        15. time-period>=?
        16. time-period-preceding
        17. time-period-succeeding
        18. time-period-contains/period?
        19. time-period-contains/time?
        20. time-period-contains/date?
        21. time-period-contains?
        22. time-period-intersects?
        23. time-period-intersection
        24. time-period-union
        25. time-period-span
        26. time-period-shift
        27. time-period-shift!
  3. Usage
  4. SRFI 29 bundles
  5. Examples
  6. Notes
  7. Bugs and Limitations
  8. Requirements
  9. Author
  10. Repository
  11. Acknowledgments
  12. Version history
  13. License

Documentation

This is a Chicken port of SRFI-19. This document only describes the extensions. For the SRFI-19 API see SRFI-19.

Core Procedures

The core procedures are those pertaining to time, date, and timezone:

(import srfi-19-core)

Or separately:

(import srfi-19-time)
(import srfi-19-date)
(import srfi-19-timezone)
(import srfi-19-support)

SRFI-19 Document Changes

The nanosecond time object element is an integer between 0 and 999,999,999 inclusive. (The SRFI-19 document mis-states the value.)

A tz-offset value follows ISO 8601; positive for east of UTC, and negative for west. This is the opposite of the POSIX TZ environment variable.

Where the SRFI-19 document states a tz-offset argument a timezone-components object is also legal.

The string->date procedure allows the template-name argument to be optional. When missing the locale's date-time-format string is used. The supplied locale bundle's strings are invertible.

make-date
[procedure] (make-date NANOSECOND SECOND MINUTE HOUR DAY MONTH YEAR [ZONE-OFFSET [TZ-NAME [DST-FLAG]]]) -> DATE

Same as SRFI-19 except for the optional parameters and allowing a timezone-components object for the ZONE-OFFSET.

The ZONE-OFFSET is an integer or timezone-components. Default is the (timezone-locale-offset), the current locale timezone offset.

The TZ-NAME is a string or #f, and is the timezone name. Default is #f.

The DST-FLAG is a boolean, and indicates whether Day Saving TIme (or Summer Time) is active. Default is #f.

When the ZONE-OFFSET is a timezone-components object the TZ-NAME and DST-FLAG are pulled from the timezone-components, unless explicitly supplied.

read-leap-second-table
[procedure] (read-leap-second-table FILENAME)

Sets the leap second table from the specified FILENAME.

The file format is the same as the "tai-utc.dat" file in the distribution. Provided by the U.S. Naval Observatory.

leap-year?
[procedure] (leap-year? DATE) -> BOOLEAN

Does the specified DATE fall on a leap year?

The DATE may be a numeric year or a date object.

SRFI-18 Time

Note that the SRFI-18 identifiers time?, current-time, seconds->time, time->seconds, milliseconds->time, and time->milliseconds are in conflict with those of SRFI-19.

time->srfi-18-time
[procedure] (time->srfi-18-time TIME) -> SRFI-18#TIME

Converts a SRFI-19 time object to a SRFI-18 time object. The conversion is really only meaningful for time-duration, but any time-type is accepted.

srfi-18-time->time
[procedure] (srfi-18-time->time TIME) -> SRFI-19#TIME

Converts a SRFI-18 time object into a SRFI-19 time-duration object.

Time Conversion

time-hash
[procedure] (time-hash TIME #!optional bnd rnd) -> INTEGER

Hash TIME.

time-copy
[procedure] (time-copy TIME) -> TIME

Returns an exact copy of the specified TIME object.

seconds->time
[procedure] (seconds->time SECONDS [TIME-TYPE time-duration]) -> TIME

Converts a SECONDS value, may be fractional, into a TIME-TYPE time object.

seconds->date
[procedure] (seconds->date SECONDS [TIMEZONE-INFO #t]) -> DATE

Converts a SECONDS value, which may be fractional, into a date object. The TIMEZONE-INFO is #t for the local timezone, #f for the utc timezone, or a timezone-components object.

SECONDS is relative to 00:00:00 January 1, 1970 UTC.

time->nanoseconds
[procedure] (time->nanoseconds TIME) -> INTEGER

Returns the TIME object value as a nanoseconds value.

nanoseconds->time
[procedure] (nanoseconds->time NANOSECONDS [TIME-TYPE time-duration]) -> TIME

Returns the NANOSECONDS value as a time TIME-TYPE object.

nanoseconds->seconds
[procedure] (nanoseconds->seconds NANOSECONDS) -> NUMBER

Returns the NANOSECONDS value as a seconds value.

time->milliseconds
[procedure] (time->milliseconds TIME) -> INTEGER

Returns the TIME object value as a milliseconds value.

milliseconds->time
[procedure] (milliseconds->time MILLISECONDS [TIME-TYPE time-duration]) -> TIME

Returns the MILLISECONDS value as a time TIME-TYPE object.

milliseconds->seconds
[procedure] (milliseconds->seconds MILLISECONDS) -> NUMBER

Returns the MILLISECONDS value as a seconds value.

time->date
[procedure] (time->date TIME) -> DATE

Returns the TIME object value as a date. A shorthand for the (time-*->date...) procedures.

time->julian-day
[procedure] (time->julian-day TIME) -> RATIONAL

Returns the julian day for the TIME object.

time->modified-julian-day
[procedure] (time->modified-julian-day TIME) -> RATIONAL

Returns the modified julian day for the TIME object.

Time Arithmetic

make-duration
[procedure] (make-duration [#:days 0] [#:hours 0] [#:minutes 0] [#:seconds 0] [#:milliseconds 0] [#:microseconds 0] [#:nanoseconds 0]) -> TIME

Returns a time-object of clock-type time-duration where the seconds and nanoseconds values are calculated by summing the keyword arguments.

one-second-duration
[procedure] (one-second-duration) -> TIME
one-nanosecond-duration
[procedure] (one-nanosecond-duration) -> TIME
zero-time
[procedure] (zero-time [TIME-TYPE time-duration]) -> TIME
TIME-FINE-GRAIN

Most minimum positive amount of time, as a duration.

divide-duration
[procedure] (divide-duration DURATION NUMBER) -> TIME

Returns a duration, from DURATION, divided by NUMBER, without remainder.

divide-duration!
[procedure] (divide-duration! DURATION NUMBER) -> TIME

Returns DURATION, divided by NUMBER, without remainder.

multiply-duration
[procedure] (multiply-duration DURATION NUMBER) -> TIME

Returns a duration, from DURATION, multiplied by NUMBER, truncated.

multiply-duration!
[procedure] (multiply-duration! DURATION NUMBER) -> TIME

Returns DURATION, multiplied by NUMBER, truncated.

time-negative?
[procedure] (time-negative? TIME) -> BOOLEAN

Is TIME negative?

A time object will never have a negative nanoseconds value.

time-positve?
[procedure] (time-positve? TIME) -> BOOLEAN

Is TIME positive?

time-zero?
[procedure] (time-zero? TIME) -> BOOLEAN

Is TIME zero?

time-abs
[procedure] (time-abs TIME) -> TIME

Returns the absolute time value, from TIME.

time-abs!
[procedure] (time-abs! TIME) -> TIME

Returns the absolute TIME value.

time-negate
[procedure] (time-negate TIME) -> TIME

Returns the sign inverted time value, from TIME.

time-negate!
[procedure] (time-negate! TIME) -> TIME

Returns the TIME sign inverted value.

Time Comparison

time-compare
[procedure] (time-compare TIME1 TIME2) -> INTEGER

Returns -1, 0, or 1.

time-max
[procedure] (time-max TIME1 [TIME2...]) -> TIME

Returns the maximum time object from TIME1 TIME2....

time-min
[procedure] (time-min TIME1 [TIME2...]) -> TIME

Returns the minimum time object from TIME1 TIME2....

Dates

default-date-clock-type
[parameter] (default-date-clock-type [CLOCK-TYPE time-utc]) -> SYMBOL

Sets or gets the clock-type used by default for conversion of a date to a time.

date-copy
[procedure] (date-copy DATE) -> DATE

Returns an exact copy of the specified DATE object.

date->seconds
[procedure] (date->seconds DATE [CLOCK-TYPE (default-date-clock-type)]) -> NUMBER

Returns the specified DATE as as a seconds value, based on the CLOCK-TYPE.

The seconds value is relative to the TAI-EPOCH - 1 January 1970 CE at 00:00:00 UTC.

date->time
[procedure] (date->time DATE [CLOCK-TYPE (default-date-clock-type)]) -> TIME

Returns the specified DATE as a time-object of type CLOCK-TYPE.

date-zone-name
[procedure] (date-zone-name DATE) -> BOOLEAN
[procedure] (date-zone-name DATE) -> STRING

Returns the timezone abbreviation of the specified DATE object. The result is either a string or #f.

date-dst?
[procedure] (date-dst? DATE) -> BOOLEAN

Returns the daylight saving time flag of the specified DATE object.

Only valid for "current" dates. Historical dates will not have a correct setting. Future dates cannot have a correct setting.

Date Arithmetic

date-difference
[procedure] (date-difference DATE1 DATE2 [CLOCK-TYPE]) -> TIME

Returns the time-duration between DATE1 and DATE2.

date-add-duration
[procedure] (date-add-duration DATE DURATION [CLOCK-TYPE]) -> DATE

Returns a new date, the DATE plus the DURATION.

date-subtract-duration
[procedure] (date-subtract-duration DATE DURATION [CLOCK-TYPE]) -> DATE

Returns a new date, the DATE minus the DURATION.

date-adjust
[procedure] (date-adjust DATE AMOUNT KEY [CLOCK-TYPE]) -> DATE

Returns a new date, the DATE adjusted by the AMOUNT of KEY.

AMOUNT
integer ;
KEY
symbol ; '(years quarters months weeks days hours minutes seconds milliseconds microseconds nanoseconds).

If the day of the month of DATE is greater than the number of days in the final month, the day of the month will change to the last day in the final month.

Adjusting a time KEY (ex: 'hours) follows the semantics of date-add-duration.

date-adjust*
[procedure] (date-adjust* DATE KEY AMOUNT ... [CLOCK-TYPE]) -> DATE

Returns a new date, the DATE adjusted by each of the KEY AMOUNT pairs, in-order.

AMOUNT
integer ;
KEY
keyword ; '(#:years #:quarters #:months #:weeks #:days #:hours #:minutes #:seconds #:milliseconds #:microseconds #:nanoseconds).

A convince wrapper of date-adjust.

Date Comparison

date-compare
[procedure] (date-compare DATE1 DATE2) -> INTEGER

Returns -1, 0, or 1.

date-hash
[procedure] (date-hash DATE #!optional bnd rnd) -> INTEGER

Hash DATE.

date=?
[procedure] (date=? DATE1 DATE2) -> BOOLEAN

Is DATE1 on DATE2?

date>?
[procedure] (date>? DATE1 DATE2) -> BOOLEAN

Is DATE1 after DATE2?

date<?
[procedure] (date<? DATE1 DATE2) -> BOOLEAN

Is DATE1 before DATE2?

date>=?
[procedure] (date>=? DATE1 DATE2) -> BOOLEAN

Is DATE1 after or on DATE2?

date<=?
[procedure] (date<=? DATE1 DATE2) -> BOOLEAN

Is DATE1 before or on DATE2?

Timezone

local-timezone-locale
[parameter] (local-timezone-locale [TZ-COMPONENTS])

Gets or sets the local timezone-locale object.

utc-timezone-locale
[parameter] (utc-timezone-locale [TZ-COMPONENTS])

Gets or sets the utc timezone-locale object.

Probably not a good idea to change the value.

timezone-locale-name
[procedure] (timezone-locale-name [TZ-COMPONENTS]) -> SYMBOL

Returns the timezone-locale name of the supplied TZ-COMPONENTS, or the (local-timezone-locale) if missing.

timezone-locale-offset
[procedure] (timezone-locale-offset [TZ-COMPONENTS]) -> INTEGER

Returns the timezone-locale offset of the supplied TZ-COMPONENTS, or the (local-timezone-locale) if missing.

timezone-locale-dst?
[procedure] (timezone-locale-dst? [TZ-COMPONENTS]) -> BOOLEAN

Returns the timezone-locale daylight saving time flag of the supplied TZ-COMPONENTS, or the (local-timezone-locale) if missing.

Input/Output Procedures

(import srfi-19-io)

DATE->STRING conversion specifiers

The SRFI-19 document does not mention the padding character override feature for the normally zero-padded conversions f, H, I, j, m, M, N, S, y. If the tilde is followed by a - then padding is suppressed. If followed by a _ the space character is used for padding. Otherwise zero-padding is perfomed, the default.

~[-_][fHIjmMNSy]

format-date
[procedure] (format-date DESTINATION DATE-FORMAT DATE)
[procedure] (format-date DATE-FORMAT DATE) -> {{STRING}}

Displays a text form of the DATE on the DESTINATION using the DATE-FORMAT.

DESTINATION
; the result is returned as a string.
DESTINATION
#f ; the result is returned as a string.
DESTINATION
#t ; the (current-output-port) is used.
DESTINATION
output-port ; text output port.
DESTINATION
number ; the (current-error-port) is the DESTINATION.
scan-date
[procedure] (scan-date SOURCE TEMPLATE) -> DATE

Reads a text form of a date from the SOURCE, following the TEMPLATE, and returns a date object.

SOURCE
#t ; (current-input-port).
SOURCE
input-port ; text input port.
SOURCE
string ; a date text form.

A partial date resulting from a time-only format, missing the d-m-y, is completed with from the (current-date), as is any timezone information, and missing h:m:s:ns are 0.

string->date
[procedure] (string->date SOURCE [TEMPLATE]) -> DATE
SOURCE
see scan-date.
TEMPLATE
string ; default (localized-template/default 'srfi-19 'date-time).
date->string
[procedure] (date->string DATE [DATE-FORMAT]) -> DATE
DATE
date
DATE-FORMAT
string ; default "~c".

Date/Time Literals

Literal Date/Time forms.

Usage

(import srfi-19-literals)
date-literal-form
[parameter] (date-literal-form [FORM]) -> BOOLEAN
[parameter] (date-literal-form [FORM]) -> SYMBOL

The date literal format.

#f
#<srfi-19#date ...>
SRFI-10
#,(srfi-19-date ...)
#t
#@... ; the default
|#@|
#@...
time-literal-form
[parameter] (time-literal-form [FORM])-> BOOLEAN
[parameter] (time-literal-form [FORM])-> SYMBOL

The time literal format.

#f
#<srfi-19#time ...>
SRFI-10
#,(srfi-19-time ...) ; the default
#t ##...
|##|
##...

Use the ## form at your peril.

read-date-literal
[procedure] (read-date-literal [PORT]) -> LIST

Read a date-literal from the PORT, in one of the supported forms, and return the object creation source form; '(make-date ....).

PORT
input-port ; default (current-input-port)

Supported forms:

"~Y-~m-~dT~H:~M:~S~z"
date time timezone
"~Y-~m-~dT~H:~M:~S"
date time
"~Y-~m-~d"
date
"~H:~M:~S~z"
time timezone; date components from (current-date)
"~H:~M:~S"
time; date components from (current-date)
write-date-literal
[procedure] (write-date-literal DATE [PORT])

Write the DATE to the PORT using a string ISO form; "~Y-~m-~dT~H:~M:~S~z".

PORT
output-port ; default (current-output-port)

Time Period

Usage

(import srfi-19-period)

A time-period is an interval, [begin end), where begin and end are time objects of the same clock type.

make-time-period
[procedure] (make-time-period BEGIN END [CLOCK-TYPE (default-date-clock-type)]) -> TIME-PERIOD

Returns a new time-period object. The clock types must be compatible.

BEGIN maybe a seconds value, a date, or a time (except time-duration). A seconds value or date are converted to CLOCK-TYPE.

END maybe a seconds value, a date, or a time. A seconds value or date are converted to the same clock type as BEGIN. A time-duration is treated as an offset from BEGIN.

time-period-copy
[procedure] (time-period-copy TIME-PERIOD) -> TIME-PERIOD

Returns a copy of TIME-PERIOD.

time-period-begin
[procedure] (time-period-begin TIME-PERIOD)

Returns the start time for the TIME-PERIOD.

time-period-end
[procedure] (time-period-end TIME-PERIOD) -> TIME

Returns the end time for the TIME-PERIOD.

time-period-last
[procedure] (time-period-last TIME-PERIOD) -> TIME

Returns the last time for the TIME-PERIOD; (time-period-end - TIME-FINE-GRAIN).

time-period-type
[procedure] (time-period-type TIME-PERIOD) -> SYMBOL

Returns the clock-type of the TIME-PERIOD.

time-period?
[procedure] (time-period? OBJECT) -> BOOLEAN

Is OBJECT a time-period?

time-period-length
[procedure] (time-period-length TIME-PERIOD) -> TIME

Returns the time-duration of the TIME-PERIOD.

time-period-hash
[procedure] (time-period-hash TIME-PERIOD #!optional bnd rnd) -> INTEGER

Hash TIME-PERIOD.

time-period-compare
[procedure] (time-period-compare TIME-PERIOD-1 TIME-PERIOD-2) -> INTEGER

Returns -1 when TIME-PERIOD-1 < TIME-PERIOD-2, 0 when TIME-PERIOD-1 = TIME-PERIOD-2 and 1 TIME-PERIOD-1 > TIME-PERIOD-2.

time-period=?
[procedure] (time-period=? TIME-PERIOD-1 TIME-PERIOD-2) -> BOOLEAN

Does TIME-PERIOD-1 begin & end with TIME-PERIOD-2?

time-period<?
[procedure] (time-period<? TIME-PERIOD-1 TIME-PERIOD-2) -> BOOLEAN

Does TIME-PERIOD-1 end before TIME-PERIOD-2 begins?

time-period>?
[procedure] (time-period>? TIME-PERIOD-1 TIME-PERIOD-2) -> BOOLEAN

Does TIME-PERIOD-1 begin after TIME-PERIOD-2 ends?

time-period<=?
[procedure] (time-period<=? TIME-PERIOD-1 TIME-PERIOD-2) -> BOOLEAN

Does TIME-PERIOD-1 end on or before TIME-PERIOD-2 begins?

time-period>=?
[procedure] (time-period>=? TIME-PERIOD-1 TIME-PERIOD-2) -> BOOLEAN

Does TIME-PERIOD-1 begin on or after TIME-PERIOD-2 ends?

time-period-preceding
[procedure] (time-period-preceding TIME-PERIOD-1 TIME-PERIOD-2) -> BOOLEAN
[procedure] (time-period-preceding TIME-PERIOD-1 TIME-PERIOD-2) -> TIME-PERIOD

Return the portion of TIME-PERIOD-1 before TIME-PERIOD-2 or #f when it doesn't precede.

time-period-succeeding
[procedure] (time-period-succeeding TIME-PERIOD-1 TIME-PERIOD-2) -> BOOLEAN
[procedure] (time-period-succeeding TIME-PERIOD-1 TIME-PERIOD-2) -> TIME-PERIOD

Return the portion of TIME-PERIOD-1 after TIME-PERIOD-2 or #f when it doesn't succeed.

time-period-contains/period?
[procedure] (time-period-contains/period? TIME-PERIOD-1 TIME-PERIOD-2) -> BOOLEAN

Is TIME-PERIOD-2 within TIME-PERIOD-1?

time-period-contains/time?
[procedure] (time-period-contains/time? TIME-PERIOD TIME) -> BOOLEAN

Is TIME within TIME-PERIOD?

TIME is converted to a compatible clock-type if possible.

time-period-contains/date?
[procedure] (time-period-contains/date? TIME-PERIOD DATE) -> BOOLEAN

Is DATE within TIME-PERIOD?

DATE is converted to a compatible time if possible.

time-period-contains?
[procedure] (time-period-contains? TIME-PERIOD OBJECT) -> BOOLEAN

Is OBJECT within TIME-PERIOD?

OBJECT maybe a time, date, or time-period.

time-period-intersects?
[procedure] (time-period-intersects? TIME-PERIOD-1 TIME-PERIOD-2) -> BOOLEAN

Does TIME-PERIOD-2 overlap TIME-PERIOD-1?

time-period-intersection
[procedure] (time-period-intersection TIME-PERIOD-1 TIME-PERIOD-2) -> BOOLEAN
[procedure] (time-period-intersection TIME-PERIOD-1 TIME-PERIOD-2) -> TIME-PERIOD

The overlapping time-period of TIME-PERIOD-2 and TIME-PERIOD-1, or #f when no overlap.

time-period-union
[procedure] (time-period-union TIME-PERIOD-1 TIME-PERIOD-2) -> BOOLEAN
[procedure] (time-period-union TIME-PERIOD-1 TIME-PERIOD-2) -> TIME-PERIOD

Returns the time-period spanned by TIME-PERIOD-1 and TIME-PERIOD-2, or #f when they do not intersect.

time-period-span
[procedure] (time-period-span TIME-PERIOD-1 TIME-PERIOD-2) -> TIME-PERIOD

Returns the time-period spanned by TIME-PERIOD-1 and TIME-PERIOD-2, including any gaps.

time-period-shift
[procedure] (time-period-shift TIME-PERIOD DURATION) -> TIME-PERIOD

Returns a copy of TIME-PERIOD shifted by DURATION.

time-period-shift!
[procedure] (time-period-shift! TIME-PERIOD DURATION) -> TIME-PERIOD

Returns TIME-PERIOD shifted by DURATION.

Usage

(import srfi-19)

SRFI 29 bundles

en
English
de
German
it
Italian
es
Spanish
nl
Dutch
pt_br
Brazilian Portuguese

Examples

;must be done before 1st invocation of a srfi-19 export
(import locale)
(set-locale-category! 'timezone
  (posix-timezone-string->timezone-components
    ;some acceptable posix tz form
    "XSX+2:00XDX+1:00:00"
    ;source of tz info
    '("POSIX" "TZ")))

;now we can use srfi-19 in our runtime tz
(import (chicken format))
(import srfi-19)
(format #t "Present Day: ~A~%Present Time: ~A~%: Hah, hah, hah.~%"
  (current-date) (current-time))
(import (only (srfi 128) make-comparator))

(define (make-date-comparator)
  (import (only srfi-19-date date? date=? date<? date-hash))
  (make-comparator date? date=? date<? date-hash) )

(define (make-time-comparator)
  (import (only srfi-19-time time? time=? time<? time-hash))
  (make-comparator time? time=? time<? time-hash) )

(define (make-time-period-comparator)
  (import (only srfi-19-period time-period? time-period=? time-period<? time-period-hash))
  (only srfi-19-period time-period? time-period=? time-period<? time-period-hash) )

Notes

Bugs and Limitations

If you are adding hours, minutes, seconds, or milliseconds, the assumption is that you want precision to the hour, and will result in a different hour.

var m = moment(new Date(2011, 2, 12, 5, 0, 0)); // the day before DST in the US
m.hours(); // 5
m.add(24, 'hours').hours(); // 6

but this implementation says 1 day = 24 hours, so same hour.

Requirements

utf8 srfi-1 srfi-18 srfi-29 srfi-69 miscmacros locale record-variants check-errors

format

Author

Kon Lovett

Repository

This egg is hosted on the CHICKEN Subversion repository:

https://anonymous@code.call-cc.org/svn/chicken-eggs/release/5/srfi-19

If you want to check out the source code repository of this egg and you are not familiar with Subversion, see this page.

Acknowledgments

Version history

4.6.0
Add date-adjust*.
4.5.2
Better time-literal-form default.
4.5.1
Fix SRFI-69 compatible time-hash, date-hash, time-period-hash.
4.5.0
Add SRFI-69/128 compatible time-hash, date-hash, time-period-hash.
4.4.10
Indicate pure procedures. Fix time conversion procedure signatures.
4.4.9
Add strong typing.
4.4.8
Fix time-copy, add time-copy/date-copy, deprecate copy-date && copy-time, add time-period interval relations.
4.4.7
.
4.4.6
Fix time-utc->date default TZ.
4.4.0
Add Date/Time source literals via the srfi-19-literals module.
4.3.2
Allow partial (time only) date read.
4.3.1
.
4.3.0
Deprecate 'srfi-10 record print form. Fix record printing.
4.3.0
nanoseconds->seconds, milliseconds->seconds, & date->seconds do not necessarily return an inexact.
4.2.1
.
4.2.0
Fix make-date w/o tz.
4.1.2
.
4.1.1
Fix seconds->date flonum argument handling.
4.1.0
Variants.
4.0.2
Add dependencies.
4.0.1
Add dependencies.
4.0.0
C5 port.

License

Copyright (C) 2009-2022 Kon Lovett. All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the Software), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED ASIS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Copyright (C) I/NET, Inc. (2000, 2002, 2003). All Rights Reserved. Copyright (C) Neodesic Corporation (2000). All Rights Reserved.

This document and translations of it may be copied and furnished to others, and derivative works that comment on or otherwise explain it or assist in its implementation may be prepared, copied, published and distributed, in whole or in part, without restriction of any kind, provided that the above copyright notice and this paragraph are included on all such copies and derivative works. However, this document itself may not be modified in any way, such as by removing the copyright notice or references to the Scheme Request For Implementation process or editors, except as needed for the purpose of developing SRFIs in which case the procedures for copyrights defined in the SRFI process must be followed, or as required to translate it into languages other than English.

The limited permissions granted above are perpetual and will not be revoked by the authors or their successors or assigns.

This document and the information contained herein is provided on an "AS IS" basis and THE AUTHOR AND THE SRFI EDITORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.