[ < ] [ > ]   [ << ] [Plus haut] [ >> ]         [Top] [Table des matières] [Index] [ ? ]

39.5 Time of Day

This section explains how to determine the current time and the time zone.

Function: current-time-string &optional time-value

This function returns the current time and date as a human-readable string. The format of the string is unvarying; the number of characters used for each part is always the same, so you can reliably use substring to extract pieces of it. It is wise to count the characters from the beginning of the string rather than from the end, as additional information may some day be added at the end.

The argument time-value, if given, specifies a time to format instead of the current time. The argument should be a list whose first two elements are integers. Thus, you can use times obtained from current-time (see below) and from file-attributes (voir Definition of file-attributes). time-value can also be a cons of two integers, but this is considered obsolete.

 
(current-time-string)
     ⇒ "Wed Oct 14 22:21:05 1987"
Function: current-time

This function returns the system's time value as a list of three integers: (high low microsec). The integers high and low combine to give the number of seconds since 0:00 January 1, 1970 UTC (Coordinated Universal Time), which is high * 2**16 + low.

The third element, microsec, gives the microseconds since the start of the current second (or 0 for systems that return time with the resolution of only one second).

The first two elements can be compared with file time values such as you get with the function file-attributes. Voir Definition of file-attributes.

Function: current-time-zone &optional time-value

This function returns a list describing the time zone that the user is in.

The value has the form (offset name). Here offset is an integer giving the number of seconds ahead of UTC (east of Greenwich). A negative value means west of Greenwich. The second element, name, is a string giving the name of the time zone. Both elements change when daylight saving time begins or ends; if the user has specified a time zone that does not use a seasonal time adjustment, then the value is constant through time.

If the operating system doesn't supply all the information necessary to compute the value, the unknown elements of the list are nil.

The argument time-value, if given, specifies a time to analyze instead of the current time. The argument should have the same form as for current-time-string (see above). Thus, you can use times obtained from current-time (see above) and from file-attributes. Voir Definition of file-attributes.

Function: set-time-zone-rule tz

This function specifies the local time zone according to tz. If tz is nil, that means to use an implementation-defined default time zone. If tz is t, that means to use Universal Time. Otherwise, tz should be a string specifying a time zone rule.

Function: float-time &optional time-value

This function returns the current time as a floating-point number of seconds since the epoch. The argument time-value, if given, specifies a time to convert instead of the current time. The argument should have the same form as for current-time-string (see above). Thus, it accepts the output of current-time and file-attributes.

Warning: Since the result is floating point, it may not be exact. Do not use this function if precise time stamps are required.


[ < ] [ > ]   [ << ] [Plus haut] [ >> ]         [Top] [Table des matières] [Index] [ ? ]

Ce document a été généré par Eric Reinbold le 13 Octobre 2007 en utilisant texi2html 1.78.