: timestamp>string ( timestamp -- str )
[ (timestamp>string) ] with-string-writer ;
-: (write-gmt-offset) ( duration -- )
+: write-hhmm ( duration -- )
[ hh ] [ mm ] bi ;
: write-gmt-offset ( gmt-offset -- )
dup instant <=> {
{ +eq+ [ drop "GMT" write ] }
- { +lt+ [ "-" write before (write-gmt-offset) ] }
- { +gt+ [ "+" write (write-gmt-offset) ] }
+ { +lt+ [ "-" write before write-hhmm ] }
+ { +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 ;
: timestamp>rfc822 ( timestamp -- str )
bi
] 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 )
#! http timestamp format
#! Example: Tue, 15 Nov 1994 08:12:31 GMT