calendar.format: Add a word to output times in the format that git uses. Rename a paren word.
parent
69a6fa72bc
commit
769af0673a
|
@ -93,14 +93,21 @@ M: timestamp year. ( timestamp -- )
|
||||||
: timestamp>string ( timestamp -- str )
|
: timestamp>string ( timestamp -- str )
|
||||||
[ (timestamp>string) ] with-string-writer ;
|
[ (timestamp>string) ] with-string-writer ;
|
||||||
|
|
||||||
: (write-gmt-offset) ( duration -- )
|
: write-hhmm ( duration -- )
|
||||||
[ hh ] [ mm ] bi ;
|
[ hh ] [ mm ] bi ;
|
||||||
|
|
||||||
: write-gmt-offset ( gmt-offset -- )
|
: write-gmt-offset ( gmt-offset -- )
|
||||||
dup instant <=> {
|
dup instant <=> {
|
||||||
{ +eq+ [ drop "GMT" write ] }
|
{ +eq+ [ drop "GMT" write ] }
|
||||||
{ +lt+ [ "-" write before (write-gmt-offset) ] }
|
{ +lt+ [ "-" write before write-hhmm ] }
|
||||||
{ +gt+ [ "+" write (write-gmt-offset) ] }
|
{ +gt+ [ "+" write write-hhmm ] }
|
||||||
|
} case ;
|
||||||
|
|
||||||
|
: write-gmt-offset-number ( gmt-offset -- )
|
||||||
|
dup instant <=> {
|
||||||
|
{ +eq+ [ drop "+0000" write ] }
|
||||||
|
{ +lt+ [ "-" write before write-hhmm ] }
|
||||||
|
{ +gt+ [ "+" write write-hhmm ] }
|
||||||
} case ;
|
} case ;
|
||||||
|
|
||||||
: timestamp>rfc822 ( timestamp -- str )
|
: timestamp>rfc822 ( timestamp -- str )
|
||||||
|
@ -112,6 +119,12 @@ M: timestamp year. ( timestamp -- )
|
||||||
bi
|
bi
|
||||||
] with-string-writer ;
|
] with-string-writer ;
|
||||||
|
|
||||||
|
: timestamp>git-time ( timestamp -- str )
|
||||||
|
[
|
||||||
|
[ { DAY " " MONTH " " D " " hh ":" mm ":" ss " " YYYY " " } formatted ]
|
||||||
|
[ gmt-offset>> write-gmt-offset-number ] bi
|
||||||
|
] with-string-writer ;
|
||||||
|
|
||||||
: timestamp>http-string ( timestamp -- str )
|
: timestamp>http-string ( timestamp -- str )
|
||||||
#! http timestamp format
|
#! http timestamp format
|
||||||
#! Example: Tue, 15 Nov 1994 08:12:31 GMT
|
#! Example: Tue, 15 Nov 1994 08:12:31 GMT
|
||||||
|
|
Loading…
Reference in New Issue