Next: , Previous: , Up: Date and Time   [Contents][Index]


15.5.4 Time-Format Conversion

The procedures described in this section convert times from one format to another.

procedure: universal-time->local-decoded-time universal-time
procedure: universal-time->global-decoded-time universal-time

Converts an argument in universal-time format to decoded-time format. The result is in the local time zone or UTC, respectively.

(pp (universal-time->local-decoded-time (get-universal-time)))
-| #[decoded-time 21]
-| (second 23)
-| (minute 57)
-| (hour 17)
-| (day 29)
-| (month 4)
-| (year 1999)
-| (day-of-week 3)
-| (daylight-savings-time 1)
-| (zone 5)

(pp (universal-time->global-decoded-time
     (get-universal-time)))
-| #[decoded-time 22]
-| (second 27)
-| (minute 57)
-| (hour 21)
-| (day 29)
-| (month 4)
-| (year 1999)
-| (day-of-week 3)
-| (daylight-savings-time 0)
-| (zone 0)
procedure: universal-time->file-time universal-time

Converts an argument in universal-time format to file-time format.

(universal-time->file-time (get-universal-time))
    ⇒ 925422988
procedure: universal-time->local-time-string universal-time
procedure: universal-time->global-time-string universal-time

Converts an argument in universal-time format to a time string. The result is in the local time zone or UTC, respectively.

(universal-time->local-time-string (get-universal-time))
    ⇒ "Thu, 29 Apr 1999 17:55:31 -0400"
(universal-time->global-time-string (get-universal-time))
    ⇒ "Thu, 29 Apr 1999 21:55:51 +0000"
procedure: decoded-time->universal-time decoded-time

Converts an argument in decoded-time format to universal-time format.

(decoded-time->universal-time (local-decoded-time))
    ⇒ 3134411942
(decoded-time->universal-time (global-decoded-time))
    ⇒ 3134411947
procedure: decoded-time->file-time decoded-time

Converts an argument in decoded-time format to file-time format.

(decoded-time->file-time (local-decoded-time))
    ⇒ 925423191
(decoded-time->file-time (global-decoded-time))
    ⇒ 925423195
procedure: decoded-time->string decoded-time

Convert an argument in decoded-time format to a time string.

(decoded-time->string (local-decoded-time))
    ⇒ "Thu, 29 Apr 1999 18:00:43 -0400"
(decoded-time->string (global-decoded-time))
    ⇒ "Thu, 29 Apr 1999 22:00:46 +0000"
procedure: file-time->universal-time file-time

Converts an argument in universal-time format to file-time format.

(file-time->universal-time (file-modification-time "/"))
    ⇒ 3133891907
procedure: file-time->local-decoded-time file-time
procedure: file-time->global-decoded-time file-time

Converts an argument in file-time format to decoded-time format. The result is in the local time zone or UTC, respectively.

(pp (file-time->local-decoded-time
     (file-modification-time "/")))
-| #[decoded-time 26]
-| (second 47)
-| (minute 31)
-| (hour 17)
-| (day 23)
-| (month 4)
-| (year 1999)
-| (day-of-week 4)
-| (daylight-savings-time 1)
-| (zone 5)

(pp (file-time->global-decoded-time
     (file-modification-time "/")))
-| #[decoded-time 27]
-| (second 47)
-| (minute 31)
-| (hour 21)
-| (day 23)
-| (month 4)
-| (year 1999)
-| (day-of-week 4)
-| (daylight-savings-time 0)
-| (zone 0)
procedure: file-time->local-time-string file-time
procedure: file-time->global-time-string file-time

Converts an argument in file-time format to a time string. The result is in the local time zone or UTC, respectively.

(file-time->local-time-string (file-modification-time "/"))
    ⇒ "Fri, 23 Apr 1999 17:31:47 -0400"
(file-time->global-time-string (file-modification-time "/"))
    ⇒ "Fri, 23 Apr 1999 21:31:47 +0000"
procedure: string->universal-time time-string

Converts a time-string argument to universal-time format.

(string->universal-time "Fri, 23 Apr 1999 21:31:47 +0000")
    ⇒ 3133888307
(string->universal-time "Fri, 23 Apr 1999 17:31:47 -0400")
    ⇒ 3133888307
procedure: string->decoded-time time-string

Converts a time-string argument to decoded-time format.

(pp (string->decoded-time "Fri, 23 Apr 1999 17:31:47 -0400"))
-| #[decoded-time 30]
-| (second 47)
-| (minute 31)
-| (hour 17)
-| (day 23)
-| (month 4)
-| (year 1999)
-| (day-of-week 4)
-| (daylight-savings-time 0)
-| (zone 4)
procedure: string->file-time time-string

Converts a time-string argument to file-time format.

(string->file-time "Fri, 23 Apr 1999 17:31:47 -0400")
    ⇒ 924899507

Next: External Representation of Time, Previous: File Time, Up: Date and Time   [Contents][Index]