Artifact
606063991324333ddc038dcb7603a23604b90c89:
0000: 3b 3b 20 43 6f 70 79 72 69 67 68 74 20 28 63 29 ;; Copyright (c)
0010: 20 32 30 30 39 20 44 65 72 69 63 6b 20 45 64 64 2009 Derick Edd
0020: 69 6e 67 74 6f 6e 2e 20 20 41 6c 6c 20 72 69 67 ington. All rig
0030: 68 74 73 20 72 65 73 65 72 76 65 64 2e 0a 3b 3b hts reserved..;;
0040: 20 4c 69 63 65 6e 73 65 64 20 75 6e 64 65 72 20 Licensed under
0050: 61 6e 20 4d 49 54 2d 73 74 79 6c 65 20 6c 69 63 an MIT-style lic
0060: 65 6e 73 65 2e 20 20 4d 79 20 6c 69 63 65 6e 73 ense. My licens
0070: 65 20 69 73 20 69 6e 20 74 68 65 20 66 69 6c 65 e is in the file
0080: 0a 3b 3b 20 6e 61 6d 65 64 20 4c 49 43 45 4e 53 .;; named LICENS
0090: 45 20 66 72 6f 6d 20 74 68 65 20 6f 72 69 67 69 E from the origi
00a0: 6e 61 6c 20 63 6f 6c 6c 65 63 74 69 6f 6e 20 74 nal collection t
00b0: 68 69 73 20 66 69 6c 65 20 69 73 20 64 69 73 74 his file is dist
00c0: 72 69 62 75 74 65 64 0a 3b 3b 20 77 69 74 68 2e ributed.;; with.
00d0: 20 20 49 66 20 74 68 69 73 20 66 69 6c 65 20 69 If this file i
00e0: 73 20 72 65 64 69 73 74 72 69 62 75 74 65 64 20 s redistributed
00f0: 77 69 74 68 20 73 6f 6d 65 20 6f 74 68 65 72 20 with some other
0100: 63 6f 6c 6c 65 63 74 69 6f 6e 2c 20 6d 79 0a 3b collection, my.;
0110: 3b 20 6c 69 63 65 6e 73 65 20 6d 75 73 74 20 61 ; license must a
0120: 6c 73 6f 20 62 65 20 69 6e 63 6c 75 64 65 64 2e lso be included.
0130: 0a 0a 28 6c 69 62 72 61 72 79 20 28 73 72 66 69 ..(library (srfi
0140: 20 73 31 39 20 74 69 6d 65 20 63 6f 6d 70 61 74 s19 time compat
0150: 29 0a 20 20 28 65 78 70 6f 72 74 0a 20 20 20 66 ). (export. f
0160: 6f 72 6d 61 74 0a 20 20 20 68 6f 73 74 3a 74 69 ormat. host:ti
0170: 6d 65 2d 72 65 73 6f 6c 75 74 69 6f 6e 0a 20 20 me-resolution.
0180: 20 68 6f 73 74 3a 63 75 72 72 65 6e 74 2d 74 69 host:current-ti
0190: 6d 65 0a 20 20 20 68 6f 73 74 3a 74 69 6d 65 2d me. host:time-
01a0: 6e 61 6e 6f 73 65 63 6f 6e 64 0a 20 20 20 68 6f nanosecond. ho
01b0: 73 74 3a 74 69 6d 65 2d 73 65 63 6f 6e 64 0a 20 st:time-second.
01c0: 20 20 68 6f 73 74 3a 74 69 6d 65 2d 67 6d 74 2d host:time-gmt-
01d0: 6f 66 66 73 65 74 29 0a 20 20 28 69 6d 70 6f 72 offset). (impor
01e0: 74 0a 20 20 20 28 72 6e 72 73 20 62 61 73 65 29 t. (rnrs base)
01f0: 0a 20 20 20 28 6f 6e 6c 79 20 28 63 6f 72 65 29 . (only (core)
0200: 20 66 6f 72 6d 61 74 20 6d 69 63 72 6f 73 65 63 format microsec
0210: 6f 6e 64 20 6d 69 63 72 6f 73 65 63 6f 6e 64 2d ond microsecond-
0220: 3e 75 74 63 29 29 0a 0a 20 20 28 64 65 66 69 6e >utc)).. (defin
0230: 65 20 68 6f 73 74 3a 74 69 6d 65 2d 72 65 73 6f e host:time-reso
0240: 6c 75 74 69 6f 6e 20 31 30 30 30 29 0a 20 20 28 lution 1000). (
0250: 64 65 66 69 6e 65 20 28 68 6f 73 74 3a 63 75 72 define (host:cur
0260: 72 65 6e 74 2d 74 69 6d 65 29 20 28 6d 69 63 72 rent-time) (micr
0270: 6f 73 65 63 6f 6e 64 29 29 0a 20 20 28 64 65 66 osecond)). (def
0280: 69 6e 65 20 28 68 6f 73 74 3a 74 69 6d 65 2d 6e ine (host:time-n
0290: 61 6e 6f 73 65 63 6f 6e 64 20 74 29 20 28 2a 20 anosecond t) (*
02a0: 28 6d 6f 64 20 74 20 31 30 30 30 30 30 30 29 20 (mod t 1000000)
02b0: 31 30 30 30 29 29 0a 20 20 28 64 65 66 69 6e 65 1000)). (define
02c0: 20 28 68 6f 73 74 3a 74 69 6d 65 2d 73 65 63 6f (host:time-seco
02d0: 6e 64 20 74 29 20 28 64 69 76 20 74 20 31 30 30 nd t) (div t 100
02e0: 30 30 30 30 29 29 0a 20 20 28 64 65 66 69 6e 65 0000)). (define
02f0: 20 28 68 6f 73 74 3a 74 69 6d 65 2d 67 6d 74 2d (host:time-gmt-
0300: 6f 66 66 73 65 74 20 74 29 20 28 2f 20 28 2d 20 offset t) (/ (-
0310: 74 20 28 6d 69 63 72 6f 73 65 63 6f 6e 64 2d 3e t (microsecond->
0320: 75 74 63 20 74 29 29 20 31 30 30 30 30 30 30 29 utc t)) 1000000)
0330: 29 0a 29 0a ).).