www.delorie.com/gnu/docs/guile/guile_416.html   search  
 
Buy GNU books!


Guile Reference Manual

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

38.5 Time

Scheme Procedure: current-time
C Function: scm_current_time ()
Return the number of seconds since 1970-01-01 00:00:00 UTC, excluding leap seconds.

Scheme Procedure: gettimeofday
C Function: scm_gettimeofday ()
Return a pair containing the number of seconds and microseconds since 1970-01-01 00:00:00 UTC, excluding leap seconds. Note: whether true microsecond resolution is available depends on the operating system.

The following procedures either accept an object representing a broken down time and return a selected component, or accept an object representing a broken down time and a value and set the component to the value. The numbers in parentheses give the usual range.

tm:sec, set-tm:sec
Seconds (0-59).
tm:min, set-tm:min
Minutes (0-59).
tm:hour, set-tm:hour
Hours (0-23).
tm:mday, set-tm:mday
Day of the month (1-31).
tm:mon, set-tm:mon
Month (0-11).
tm:year, set-tm:year
Year (70-), the year minus 1900.
tm:wday, set-tm:wday
Day of the week (0-6) with Sunday represented as 0.
tm:yday, set-tm:yday
Day of the year (0-364, 365 in leap years).
tm:isdst, set-tm:isdst
Daylight saving indicator (0 for "no", greater than 0 for "yes", less than 0 for "unknown").
tm:gmtoff, set-tm:gmtoff
Time zone offset in seconds west of UTC (-46800 to 43200).
tm:zone, set-tm:zone
Time zone label (a string), not necessarily unique.

Scheme Procedure: localtime time [zone]
C Function: scm_localtime (time, zone)
Return an object representing the broken down components of time, an integer like the one returned by current-time. The time zone for the calculation is optionally specified by zone (a string), otherwise the TZ environment variable or the system default is used.

Scheme Procedure: gmtime time
C Function: scm_gmtime (time)
Return an object representing the broken down components of time, an integer like the one returned by current-time. The values are calculated for UTC.

Scheme Procedure: mktime sbd_time [zone]
C Function: scm_mktime (sbd_time, zone)
bd-time is an object representing broken down time and zone is an optional time zone specifier (otherwise the TZ environment variable or the system default is used).

Returns a pair: the car is a corresponding integer time value like that returned by current-time; the cdr is a broken down time object, similar to as bd-time but with normalized values.

Scheme Procedure: tzset
C Function: scm_tzset ()
Initialize the timezone from the TZ environment variable or the system default. It's not usually necessary to call this procedure since it's done automatically by other procedures that depend on the timezone.

Scheme Procedure: strftime format stime
C Function: scm_strftime (format, stime)
Formats a time specification time using template. time is an object with time components in the form returned by localtime or gmtime. template is a string which can include formatting specifications introduced by a % character. The formatting of month and day names is dependent on the current locale. The value returned is the formatted string. See section `Formatting Date and Time' in The GNU C Library Reference Manual.)

 
(strftime "%c" (localtime (current-time)))
=> "Mon Mar 11 20:17:43 2002"

Scheme Procedure: strptime format string
C Function: scm_strptime (format, string)
Performs the reverse action to strftime, parsing string according to the specification supplied in template. The interpretation of month and day names is dependent on the current locale. The value returned is a pair. The car has an object with time components in the form returned by localtime or gmtime, but the time zone components are not usefully set. The cdr reports the number of characters from string which were used for the conversion.

Variable: internal-time-units-per-second
The value of this variable is the number of time units per second reported by the following procedures.

Scheme Procedure: times
C Function: scm_times ()
Return an object with information about real and processor time. The following procedures accept such an object as an argument and return a selected component:

tms:clock
The current real time, expressed as time units relative to an arbitrary base.
tms:utime
The CPU time units used by the calling process.
tms:stime
The CPU time units used by the system on behalf of the calling process.
tms:cutime
The CPU time units used by terminated child processes of the calling process, whose status has been collected (e.g., using waitpid).
tms:cstime
Similarly, the CPU times units used by the system on behalf of terminated child processes.

Scheme Procedure: get-internal-real-time
C Function: scm_get_internal_real_time ()
Return the number of time units since the interpreter was started.

Scheme Procedure: get-internal-run-time
C Function: scm_get_internal_run_time ()
Return the number of time units of processor time used by the interpreter. Both system and user time are included but subprocesses are not.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

  webmaster     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003