calendar -- refactor printing the time
parent
f0f291d8ff
commit
82b312e316
|
@ -264,17 +264,25 @@ M: number +second ( timestamp n -- timestamp )
|
||||||
: print-year ( year -- )
|
: print-year ( year -- )
|
||||||
12 [ 1+ print-month terpri ] each-with ;
|
12 [ 1+ print-month terpri ] each-with ;
|
||||||
|
|
||||||
: timestamp>http-string ( timestamp -- string )
|
: (timestamp>string) ( timestamp -- )
|
||||||
#! http timestamp format
|
dup day-of-week day-abbreviations3 nth write ", " write
|
||||||
#! Example: Tue, 15 Nov 1994 08:12:31 GMT
|
dup timestamp-day unparse write bl
|
||||||
>gmt
|
dup timestamp-month months-abbreviations nth write bl
|
||||||
|
dup timestamp-year unparse write bl
|
||||||
|
dup timestamp-hour unparse 2 CHAR: 0 pad-left write ":" write
|
||||||
|
dup timestamp-minute unparse 2 CHAR: 0 pad-left write ":" write
|
||||||
|
timestamp-second >fixnum unparse 2 CHAR: 0 pad-left write ;
|
||||||
|
|
||||||
|
: timestamp>string ( timestamp -- str )
|
||||||
[
|
[
|
||||||
dup day-of-week day-abbreviations3 nth write ", " write
|
(timestamp>string)
|
||||||
dup timestamp-day unparse write bl
|
] string-out ;
|
||||||
dup timestamp-month months-abbreviations nth write bl
|
|
||||||
dup timestamp-year unparse write bl
|
: timestamp>http-string ( timestamp -- str )
|
||||||
dup timestamp-hour unparse 2 CHAR: 0 pad-left write ":" write
|
#! http timestamp format
|
||||||
dup timestamp-minute unparse 2 CHAR: 0 pad-left write ":" write
|
#! Example: Tue, 15 Nov 1994 08:12:31 GMT
|
||||||
timestamp-second >fixnum unparse 2 CHAR: 0 pad-left write " GMT" write
|
>gmt [
|
||||||
|
(timestamp>string)
|
||||||
|
" GMT" write
|
||||||
] string-out ;
|
] string-out ;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue