This is the date and time library, on which many LAML facilities rely.
Time is represented as an integer, which represents the number of seconds since January 1, 1970.
This library contains functions which translate from seconds to year, month, day, hour, and second.
Also the reverse translation is provided for. Besides this, the library provides functions for calculating the weekday and
the week number.
Weekday and month names can be returned in either Danish og English, depending on the variable language-preference.
The language-preference binds at a late time, not loadning time.
Be aware that you need to modify the variable time-zone-info when summer and winter times are introduced.
1 Time zone and Daylight Saving Time correction. |
|
|
time-zone-info |
Form | time-zone-info |
Description | Defines the time-zone. We also use this variable to adjust for daylight saving time.
This is, however, kind of a hack.
How many hours in front relative to Greenwich, England.
The US east coast: 5. California 8. Denmark -1
If the encoded time happens to be greenwich time, time-zone-info
should be non-zero in order to correct the time. If the encoded
time is already corrected on your system, time-zone-info must be 0. |
|
2 Basic time functions. |
According to LAML conventions, the function current-time is assumed to return the current time,
represented as the number of seconds elapsed since January 1, 1970, 00:00:00.
In this section there are functions that encode and decode a number of seconds to and from
a conventional time representation (in terms of year, month, day, hour, minutes, second). |
|
time-decode |
Form | (time-decode n) |
Description | Given an integer n, which is the number of second since january 1, 1970,
return a list: (year month day minutes seconds).
The opposite function is called second-count |
|
second-count |
Form | (second-count y mo d h mi s) |
Description | Given date and time in terms of year y, month mo, day d, hour h, minutes mi, and seconds s, caluculate the second count.
The second-count function compensates for time zone.
The opposite function is called date-time. |
|
time-encode |
Form | (time-encode y mo d h mi s) |
Description | An alias of second-count - encode year, month, day, hour, minutes, and seconds to an integer. |
|
3 Time selectors. |
The selectors in this section work on decoded time lists. It means that
the selectors just return a given element from the decoded list representation of time. |
|
year-of-time |
Form | (year-of-time decoded-time-list) |
Description | Return the year of a decoded time list. An integer greater or equal to 1970. |
|
month-of-time |
Form | (month-of-time decoded-time-list) |
Description | Return the month of a decoded time list. An integer in the interval 1..12 |
|
day-of-time |
Form | (day-of-time decoded-time-list) |
Description | Return the days of a decoded time list. An integer in the interval 1..31 |
|
hour-of-time |
Form | (hour-of-time decoded-time-list) |
Description | Return the hour of a decoded time list. An integer in the interval 0..23 |
|
minute-of-time |
Form | (minute-of-time decoded-time-list) |
Description | Return the minutes of a decoded time list. An integer in the interval 0..59. |
|
second-of-time |
Form | (seconds-of-time decoded-time-list) |
Description | Return the seconds of a decoded time list. An integer in the interval 0..59. |
|
4 Week days. |
The functions in this section deal with week days. Both English and Danish week day names are supported
the the variable language-preference in laml.scm. |
|
weekday |
Form | (weekday second-count) |
Description | Given an integer, second-count, return the weekday of the time second-count. |
|
brief-weekday |
Form | (brief-weekday second-count) |
Description | Given an integer, second-count, return the weekday as a brief string, of the time second-count. |
|
5 Week number and week day number. |
The functions in this section deal with week numbering and, more simple, week day numbering. |
|
danish-week-number |
Form | (danish-week-number sc) |
Description | Given a number sc, return the week number in which sc i located.
Weeknumbers are treated by means of Danish weeknumber rules |
|
weekday-number |
Form | (weekday-number second-count) |
Description | Return the weekday-number of second-count (an integer). Monday is day number 1 in the week, sunday is day number 7. |
|
6 Time pretty printing. |
The functions in this section return pretty printed string representation of time. |
|
date-time |
Form | (date-time second-count) |
Description | Given an integer, second-cound, return a list of two strings: (date time).
This is useful in cases you need to print the data or time as a string.
Takes the variable language preference into account. |
|
date-time-one-string |
Form | (date-time-one-string second-count) |
Description | Return a single string that pretty prints the time represented by second count.
Takes the variable language preference into account. |
|
when-generated |
Form | (when-generated) |
Description | Return a string that describes the current time as generation time.
Takes the variable language preference into account. |
|
7 Time interval functions. |
|
|
time-interval |
Form | (time-interval second-count) |
Description | Return the number of years, months, weeks, days, hours, minutes, and seconds
from second-count. A list of integers is returned. |
|
present-time-interval |
Form | (present-time-interval second-count) |
Description | Return a string which presens the number of years, months, weeks, days, hours, minutes, and seconds
of second-count |
|
8 Conventional string representation of time. |
This section contains a number of functions that deal with dates and time as strings in the formats: "ddmmyyyy" and "hhmm".
The seconds are not part of the string representation. |
|
transform-year-month-day-hour-minutes-strings |
Form | (transform-year-month-day-hour-minutes-strings date time) |
Description | Transform date and time strings to a second count (a large integer number of seconds elapsed since january 1, 1970).
The date parameter is a string of the form "ddmmyyyy" (eight ciffers).
The time parameter is of the form "hhmm" (four ciffers).
Assumes as a prefix that date and time represent a legal point in time. Use date-ok? and time-ok? to assure this.
Return #f if date is blank (or if both date and time is blank). |
|
date-string |
Form | (date-string second-count) |
Description | Return the date, in the format "ddmmyyyy" of second-count,
which represents the time in seconds elapsed since January 1, 1970. |
|
time-string |
Form | (time-string second-count) |
Description | Return the date, in the format "ddmmyyyy" of second-count,
which represents the time in seconds elapsed since January 1, 1970. |
|
date-ok? |
Form | (date-ok? x) |
Description | Return whether x is a legal date string (of the form "ddmmyyyy")
Exact determination, including february and leap years.
Uses days-in-month from the time library. |
|
time-ok? |
Form | (time-ok? x) |
Description | Return whether x is a legal time string (of the form "hhmm") |
|
9 Underlying time related functions. |
In this section there is a number of more basic, but still useful time related functions and constants. |
|
get-month-name |
Form | (get-month-name month-number) |
Description | Return the month name of month-number. January is number one.
The result depends on the free variable language preference. |
|
leap-year |
Form | (leap-year y) |
Description | Return whether y is a leap year. |
|
days-in-month |
Form | (days-in-month month year) |
Description | Return the number of days in month and year |
|