C: <timestamp> timestamp
: gmt-offset-duration ( -- duration )
- 0 0 0 gmt-offset <duration> ;
+ 0 0 0 gmt-offset <duration> ; inline
: <date> ( year month day -- timestamp )
- 0 0 0 gmt-offset-duration <timestamp> ;
+ 0 0 0 gmt-offset-duration <timestamp> ; inline
: <date-gmt> ( year month day -- timestamp )
- 0 0 0 instant <timestamp> ;
+ 0 0 0 instant <timestamp> ; inline
: <year> ( year -- timestamp )
- 1 1 <date> ;
+ 1 1 <date> ; inline
: <year-gmt> ( year -- timestamp )
- 1 1 <date-gmt> ;
+ 1 1 <date-gmt> ; inline
ERROR: not-a-month ;
M: not-a-month summary
before time+ ;
: <zero> ( -- timestamp )
- 0 0 0 0 0 0 instant <timestamp> ;
+ 0 0 0 <date-gmt> ; inline
: valid-timestamp? ( timestamp -- ? )
clone instant >>gmt-offset
dup <zero> time- <zero> time+ = ;
: unix-1970 ( -- timestamp )
- 1970 1 1 0 0 0 instant <timestamp> ;
+ 1970 <year-gmt> ; inline
: millis>timestamp ( x -- timestamp )
[ unix-1970 ] dip milliseconds time+ ;
M: integer end-of-year 12 31 <date> ;
: time-since-midnight ( timestamp -- duration )
- dup midnight time- ;
+ dup midnight time- ; inline
: since-1970 ( duration -- timestamp )
- unix-1970 time+ ;
+ unix-1970 time+ ; inline
: timestamp>unix-time ( timestamp -- seconds )
- unix-1970 time- second>> ;
+ unix-1970 time- second>> ; inline
: unix-time>timestamp ( seconds -- timestamp )
- seconds unix-1970 time+ ;
+ seconds since-1970 ; inline
{
{ [ os unix? ] [ "calendar.unix" ] }
read-sp checked-number >>year\r
":" read-token checked-number >>hour\r
":" read-token checked-number >>minute\r
- " " read-token checked-number >>second\r
+ read-sp checked-number >>second\r
readln parse-rfc822-gmt-offset >>gmt-offset ;\r
\r
: rfc822>timestamp ( str -- timestamp )\r
read-sp checked-number >>year\r
":" read-token checked-number >>hour\r
":" read-token checked-number >>minute\r
- " " read-token checked-number >>second\r
+ read-sp checked-number >>second\r
readln parse-rfc822-gmt-offset >>gmt-offset ;\r
\r
: cookie-string>timestamp-1 ( str -- timestamp )\r
read-sp checked-number >>day\r
":" read-token checked-number >>hour\r
":" read-token checked-number >>minute\r
- " " read-token checked-number >>second\r
+ read-sp checked-number >>second\r
read-sp checked-number >>year\r
readln parse-rfc822-gmt-offset >>gmt-offset ;\r
\r
TYPEDEF: double CFTimeInterval
TYPEDEF: double CFAbsoluteTime
-: >CFTimeInterval ( duration -- interval )
- duration>seconds ; inline
+ALIAS: >CFTimeInterval duration>seconds
MEMO: epoch ( -- micros )
T{ timestamp { year 2001 } { month 1 } { day 1 } } timestamp>micros ;
bi-curry '[ _ _ bi ]
] if ;
-: nappend-as ( n exemplar -- seq )
- [ narray concat ] dip like ; inline
-
: nappend ( n -- seq ) narray concat ; inline
+: nappend-as ( n exemplar -- seq )
+ [ nappend ] dip like ; inline
+
MACRO: nmin-length ( n -- )
dup 1 - [ min ] n*quot
'[ [ length ] _ napply @ ] ;
[ t ] [ "hello how are you?" lower? ] unit-test
[
[ f ] [ i-dot? ] unit-test
- [ f ] [ lt? ] unit-test
+ [ f ] [ lithuanian? ] unit-test
"tr" locale set
[ t ] [ i-dot? ] unit-test
- [ f ] [ lt? ] unit-test
+ [ f ] [ lithuanian? ] unit-test
[ "i\u000131i \u000131jj" ] [ "i\u000131I\u000307 IJj" >lower ] unit-test
[ "I\u000307\u000131i Ijj" ] [ "i\u000131I\u000307 IJj" >title ] unit-test
[ "I\u000307II\u000307 IJJ" ] [ "i\u000131I\u000307 IJj" >upper ] unit-test
"lt" locale set
[ f ] [ i-dot? ] unit-test
- [ t ] [ lt? ] unit-test
+ [ t ] [ lithuanian? ] unit-test
[ "i\u000307\u000300" ] [ HEX: CC 1string nfd >lower ] unit-test
[ "\u00012f\u000307" ] [ HEX: 12E 1string nfd >lower nfc ] unit-test
[ "I\u000300" ] [ "i\u000307\u000300" >upper ] unit-test
: i-dot? ( -- ? )
locale get { "tr" "az" } member? ;
-: lt? ( -- ? )
- locale get "lt" = ;
-
: lithuanian? ( -- ? ) locale get "lt" = ;
: lithuanian>upper ( string -- lower )
: >lower ( string -- lower )
i-dot? [ turk>lower ] when
- lt? [ lithuanian>lower ] when
+ lithuanian? [ lithuanian>lower ] when
final-sigma
[ lower>> ] [ ch>lower ] map-case ;
: >upper ( string -- upper )
i-dot? [ turk>upper ] when
- lt? [ lithuanian>upper ] when
+ lithuanian? [ lithuanian>upper ] when
[ upper>> ] [ ch>upper ] map-case ;
HINTS: >upper string ;
: (>title) ( string -- title )
i-dot? [ turk>upper ] when
- lt? [ lithuanian>upper ] when
+ lithuanian? [ lithuanian>upper ] when
[ title>> ] [ ch>title ] map-case ; inline
PRIVATE>