(sph time)

time as tai or utc nanoseconds since the unix epoch or gregorian calendar dates.

part of sph-lib

library description

get, manipulate and convert dates and times in scheme.

uses a proleptic gregorian calendar with negative years and a year 0 equivalent to 1 BCE

iso8601 and the gnu date utility include a year zero as well, to which the output is compatible.

international atomic time is used because it does not use leap seconds. with utc it is

not predictable when future leap seconds will be inserted, which makes it impossible to calculate accurate future times with utc.

the implementation does not depend on other time libraries, only on a function that gives the current utc posixtime.

it might also contain useful examples for calendar and time calculation implementors.


  utc: integer: utc seconds since the unix epoch. utc uses leap seconds to conform to (= number-of-days (/ utc-seconds 86400))

  tai: integer: tai seconds since the unix epoch. as elapsed, no leap seconds

  date: vector: gregorian calendar date, daytime and timezone offset

module name

(sph time)

exported bindings

procedure: date->week-day a ->
from 0-6, with monday being the first day of the week
procedure: date-add-day a ->
procedure: date-day a ->
procedure: date-hour a ->
procedure: date-minute a ->
procedure: date-month a ->
procedure: date-nanosecond a ->
procedure: date-new #:year #:month #:day #:hour #:minute #:second #:nanosecond #:offset ->
create a date object
procedure: date-new* [year month day hour minute second nanosecond offset] ->
like date-new but the arguments are not keyword arguments
procedure: date-offset a ->
procedure: date-second a ->
procedure: date-week-count a ->
procedure: date-year a ->
procedure: nanoseconds->hms& a c ->
procedure: nanoseconds->seconds a ->
procedure: ns->s a ->
procedure: s->ns a ->
procedure: seconds->nanoseconds a ->
variable: sph-time-description
procedure: tai->utc a ->
integer -> integer
convert tai time to utc time
procedure: tai-add-minutes a minutes ->
add minutes to tai or utc time
procedure: tai-add-seconds a seconds ->
add seconds to tai or utc time
procedure: tai-current ->
current tai seconds since the unix epoch
procedure: tai-from-utc a ->
integer -> integer
convert utc time to tai time
procedure: utc->date a ->
procedure: utc->days a ->
procedure: utc->hours a ->
procedure: utc->minutes a ->
procedure: utc->seconds a ->
procedure: utc->week a ->
integer -> integer
procedure: utc->week-day a ->
from 0-6, with monday being the first day of the week
procedure: utc->year a ->
procedure: utc->years a ->
procedure: utc-add-day a days ->
procedure: utc-add-hours a hours ->
procedure: utc-add-weeks a weeks ->
procedure: utc-add-years a years ->
procedure: utc-current ->
-> integer
procedure: utc-days a ->
procedure: utc-days-and-rest& a c ->
procedure: utc-elapsed-day a ->
procedure: utc-elapsed-hour a ->
procedure: utc-elapsed-minute a ->
procedure: utc-elapsed-month a ->
procedure: utc-elapsed-year a ->
procedure: utc-from-date a ->
procedure: utc-from-days a ->
procedure: utc-from-hours a ->
procedure: utc-from-minutes a ->
procedure: utc-from-year a ->
procedure: utc-from-years a ->
procedure: utc-start-day a ->
procedure: utc-start-first-week a ->
iso standard first week of current year of time.
based on if thursday falls into the first week-days of the year
procedure: utc-start-hour a ->
procedure: utc-start-last-week a ->
the start of the last week of the year
procedure: utc-start-minute a ->
procedure: utc-start-month a ->
procedure: utc-start-second a ->
procedure: utc-start-week a ->
procedure: utc-start-year a ->
procedure: utc-year a ->
procedure: utc-zone-offset ->
get the current local system timezone offset