Generated: January 16, 2003, 23:30:14Copyright ©2003, Kurt NørmarkThe local LAML software home page

Reference Manual of the time library

Kurt Nørmark ©    normark@cs.auc.dk    Department of Computer Science    Aalborg University    Denmark    

Master index
Source file: lib/time.scm
LAML Version 19.00 (January 16, 2003, full)

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.

Table of Contents:
1. Basic time functions.4. Week number and week day number.7. Conventional string representation of time.
2. Time selectors.5. Time pretty printing.8. Underlying time related functions.
3. Week days.6. Time interval functions.

Alphabetic index:
brief-weekday(brief-weekday second-count)Given an integer, second-count, return the weekday as a brief string, of the time second-count.
danish-week-number(danish-week-number sc)Given a number sc, return the week number in which sc i located.
date-ok?(date-ok? x)Return whether x is a legal date string (of the form "ddmmyyyy") Exact determination, including february and leap years.
date-string(date-string second-count)Return the date, in the format "ddmmyyyy" of second-count, which represents the time in seconds elapsed since January 1, 1970.
date-time(date-time second-count)Given an integer, second-cound, return a list of two strings: (date time).
date-time-one-string(date-time-one-string second-count)Return a single string that pretty prints the time represented by second count.
day-of-time(day-of-time decoded-time-list)Return the days of a decoded time list.
days-in-month(days-in-month month year)Return the number of days in month and year
get-month-name(get-month-name month-number)Return the month name of month-number.
hour-of-time(hour-of-time decoded-time-list)Return the hour of a decoded time list.
leap-year(leap-year y)Return whether y is a leap year.
minute-of-time(minute-of-time decoded-time-list)Return the minutes of a decoded time list.
month-of-time(month-of-time decoded-time-list)Return the month of a decoded time list.
present-time-interval(present-time-interval second-count)Return a string which presens the number of years, months, weeks, days, hours, minutes, and seconds of second-count
second-count(second-count y mo d h mi s)Given date and time in terms of year y, month mo, day d, hour h, minutes mi, and seconds s, caluculate the second count.
second-of-time(seconds-of-time decoded-time-list)Return the seconds of a decoded time list.
time-decode(time-decode n)Given an integer n, which is the number of second since january 1, 1970, return a list: (year month day minutes seconds).
time-encode(time-encode y mo d h mi s)An alias of second-count - encode year, month, day, hour, minutes, and seconds to an integer.
time-interval(time-interval second-count)Return the number of years, months, weeks, days, hours, minutes, and seconds from second-count.
time-ok?(time-ok? x)Return whether x is a legal time string (of the form "hhmm")
time-string(time-string second-count)Return the date, in the format "ddmmyyyy" of second-count, which represents the time in seconds elapsed since January 1, 1970.
time-zone-infotime-zone-infoDefines the time-zone.
transform-year-month-day-hour-minutes-strings(transform-year-month-day-hour-minutes-strings date time)Transform date and time strings to a second count (a large integer number of seconds elapsed since january 1, 1970).
weekday(weekday second-count)Given an integer, second-count, return the weekday of the time second-count.
weekday-number(weekday-number second-count)Return the weekday-number of second-count (an integer).
when-generated(when-generated)Return a string that describes the current time as generation time.
year-of-time(year-of-time decoded-time-list)Return the year of a decoded time list.

 

1.   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.


 

2.   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.


 

3.   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.


 

4.   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.


 

5.   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.


 

6.   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


 

7.   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")


 

8.   UNDERLYING TIME RELATED FUNCTIONS.
In this section there is a number of more basic, but still useful time related functions and constants.


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, a hack. We should really go for a better solution.


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


Generated: January 16, 2003, 23:30:14
This documentation has been extracted automatically from the Scheme source file by means of the Schemedoc tool