day-abbreviations2 " " join print ;
: days. ( year month -- )
- [ 1 zeller-congruence dup [ " " write ] times ]
+ [ 1 (day-of-week) dup [ " " write ] times ]
[ (days-in-month) ] 2bi [1,b] [
[ day. ] [ + 7 mod zero? [ nl ] [ bl ] if ] bi
] with each nl ;
PRIVATE>
-GENERIC: month. ( obj -- )
-
-M: array month.
- first2 [ month-header. ] [ days-header. days. ] 2bi ;
-
-M: timestamp month.
- [ year>> ] [ month>> ] bi 2array month. ;
+: month. ( timestamp -- )
+ [ year>> ] [ month>> ] bi
+ [ month-header. ] [ days-header. days. ] 2bi ;
GENERIC: year. ( obj -- )
: write-rfc1036 ( timestamp -- )
{
- DAY ", " DD "-" MONTH "-" YYYY " " hh ":" mm ":" ss " "
+ DAY ", " DD "-" MONTH "-" YYYY " " hh:mm:ss " "
[ gmt-offset>> write-gmt-offset ]
} formatted ;
: write-rfc2822 ( timestamp -- )
{
- DAY ", " D " " MONTH " " YYYY " " hh ":" mm ":" ss " "
+ DAY ", " D " " MONTH " " YYYY " " hh:mm:ss " "
[ gmt-offset>> write-gmt-offset ]
} formatted ;
: write-rfc3339 ( timestamp -- )
{
- YYYY "-" MM "-" DD "T" hh ":" mm ":" ss.SSSSSS
+ YYYY-MM-DD "T" hh:mm:ss.SSSSSS
[ gmt-offset>> write-gmt-offset-z ]
} formatted ;
: write-iso8601 ( timestamp -- )
{
- YYYY "-" MM "-" DD "T" hh ":" mm ":" ss.SSSSSS
+ YYYY-MM-DD "T" hh:mm:ss.SSSSSS
[ gmt-offset>> write-gmt-offset-hh:mm ]
} formatted ;
: write-ctime ( timestamp -- )
{
- DAY " " MONTH " " DD " " hh ":" mm ":" ss " " YYYY
+ DAY " " MONTH " " DD " " hh:mm:ss " " YYYY
} formatted ;
: timestamp>ctime-string ( timestamp -- str )
: timestamp>git-string ( timestamp -- str )
[
{
- DAY " " MONTH " " D " " hh ":" mm ":" ss " " YYYY " "
+ DAY " " MONTH " " D " " hh:mm:ss " " YYYY " "
[ gmt-offset>> write-gmt-offset-hhmm ]
} formatted
] with-string-writer ;
>gmt timestamp>rfc1036 ;
: write-timestamp ( timestamp -- )
- { DAY ", " D " " MONTH " " YYYY " " hh ":" mm ":" ss } formatted ;
+ { DAY ", " D " " MONTH " " YYYY " " hh:mm:ss } formatted ;
: timestamp>string ( timestamp -- str )
[ write-timestamp ] with-string-writer ;
[ duration>minutes >integer 60 mod pad-00 ] bi ":" glue ;
: duration>hms ( duration -- str )
- [ duration>hm ] [ second>> >integer 60 mod pad-00 ] bi ":" glue ;
+ [ duration>hm ]
+ [ duration>seconds >integer 60 mod pad-00 ] bi ":" glue ;
: duration>human-readable ( duration -- string )
[