2017-08-27

(sph time gregorian)

gregorian calendar calculations

part of sph-lib

library description

uses a year 0 like iso8601. a year 0 supposedly keeps leap-day calculations simpler

import name

(sph time gregorian)

exports

greg-days->leap-days

procedure

signature

a ->

integer -> integer

description

gives the number of leap days in a given time span of full days.

works with positive and negative day values and considers partial years where the leap day always falls on february 29

greg-days->year

procedure

signature

a ->

greg-days->year-days

procedure

signature

a leap-year? ->

description

gives the number of days elapsed in a year. handles negative years/days

greg-days->years

procedure

signature

a ->

integer -> integer

description

the number of years the given number of days fill

greg-month->days

procedure

signature

a leap-year? ->

integer boolean -> integer

description

gives the number of days needed to reach the first day of the given month.

months are from 1-12

greg-month-days

variable

greg-month-days-get

syntax

signature

leap-year?

greg-month-days-leap-year

variable

greg-number-of-months

variable

greg-week-day

procedure

signature

year month day ->

integer integer integer -> integer

description

0 being monday

greg-year-1970-days

variable

greg-year->years

procedure

signature

a ->

greg-year-days

variable

greg-year-days->month-and-day&

procedure

signature

a greg-month-days c ->

integer #(days-of-month ...) procedure:{month day -> any} -> any

description

get the month and month day after the given number of days have passed starting from the beginning of the year

greg-year-days-leap-year

variable

greg-year-first-week-day

procedure

signature

a ->

integer:year-number -> integer:0-6:week-day-number

greg-year-leap-year?

procedure

signature

a ->

integer:year-number -> boolean

description

check if the given year is a leap year

greg-year-weeks-53?

procedure

signature

a ->

integer:year-number -> boolean

description

check if the given year number corresponds to a year with 53 instead of 52 weeks according to the iso8601 standard

greg-years->days

procedure

signature

a ->

integer -> integer

description

gives the days contained in given number of fully elapsed years

greg-years->leap-days

procedure

signature

a ->

integer -> integer

description

the number of leap days that occured when given years have elapsed from the first day of the calendar.

negative values for negative years

year 0 is a leap year and begins after -1 years. the fifth negative year completes a leap year. the fourth (positive) year completes a new year

greg-years->year

procedure

signature

a ->

description

does not work reliably when year is negative and part of a date with advanced months or days,

because advancing days in a negative year reduce the number of elapsed years but not the year number

sph-time-gregorian-description

variable

tags: programming guile documentation library scheme sph-lib q1 computer time gregorian highlight sph-time-gregorian