User Tools


This shows you the differences between two versions of the page.

Link to this comparison view

cl:functions:get-universal-time [2019/06/15 02:00]
cl:functions:get-universal-time [2019/06/18 10:00] (current)
Line 1: Line 1:
 +====== Function GET-UNIVERSAL-TIME,​ GET-DECODED-TIME ======
 +  * **get-universal-time** → //​universal-time//​
 +  * **get-decoded-time** → //second, minute, hour, date, month, year, day, daylight-p, zone//
 +====Arguments and Values====
 +  * //​universal-time//​ - a //​[[CL:​Glossary:​universal time]]//.
 +  * //second//, //minute//, //hour//, //date//, //month//, //year//, //day//, //​daylight-p//,​ //zone// - a //​[[CL:​Glossary:​decoded time]]//.
 +**get-universal-time** returns the current time, represented as a //​[[CL:​Glossary:​universal time]]//.
 +**get-decoded-time** returns the current time, represented as a //​[[CL:​Glossary:​decoded time]]//.
 +;;; TODO: should the DATE and DAY variables really be called like 
 +;;; this? They are confusing. ~phoe
 +;;; At noon on July 4, 1976 in Eastern Daylight Time.
 +(get-decoded-time) ​
 +0     ; second
 +0     ; minute
 +12    ; hour
 +4     ; date - day of month
 +7     ; month
 +1976  ; year
 +6     ; day - day of week
 +//​[[CL:​Glossary:​true]]// ​ ; daylight-p
 +5     ; timezone</​r>​
 +;;; At exactly the same instant.
 +(get-universal-time) <​r>​2414332800</​r>​
 +;;; Exactly five minutes later.
 +(get-universal-time) <​r>​2414333100</​r>​
 +;;; The difference is 300 seconds (five minutes)
 +([[CL:​Functions:​math-subtract|-]] [[CL:​Variables:​star|*]] [[CL:​Variables:​star-star|**]]) <​r>​300</​r>​
 +====Side Effects====
 +====Affected By====
 +The time of day (i.e. the passage of time), the system clock'​s ability to keep accurate time, and the accuracy of the system clock'​s initial setting.
 +====Exceptional Situations====
 +An error of type **[[CL:​Types:​error]]** might be signaled if the current time cannot be determined.
 +====See Also====
 +**[[CL:​Functions:​decode-universal-time]]**,​ **[[CL:​Functions:​encode-universal-time]]**,​ {\secref\Time}
 +(get-decoded-time) ≡ ([[CL:​Functions:​decode-universal-time]] (get-universal-time))
 +No //​[[CL:​Glossary:​implementation]]//​ is required to have a way to verify that the time returned is correct. However, if an //​[[CL:​Glossary:​implementation]]//​ provides a validity check (//e.g.// the failure to have properly initialized the system clock can be reliably detected) and that validity check fails, the //​[[CL:​Glossary:​implementation]]//​ is strongly encouraged (but not required) to signal an error of type **[[CL:​Types:​error]]** (rather than, for example, returning a known-to-be-wrong value) that is //​[[CL:​Glossary:​correctable]]//​ by allowing the user to interactively set the correct time.