Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- USING: io.encodings.utf8 combinators combinators.smart calendar
- io kernel math sequences splitting formatting.private ascii calendar.unix io.files
- calendar.format ;
- IN: prova
- ! : read-historic (fname -- a ) current-timeval timeval>seconds ;
- ! : file-lines (fname -- arr ) utf8 <file-reader> [ readln ] with-input-stream ;
- ! "/tmp/times.txt" utf8 file-lines
- ! current-timeval timeval>unix-time >date
- ! unix-time>timestamp
- ! "2017-03-29 00:00:00" ymdhms>timestamp
- ! regexes are crap
- : in/out-for-timestamp ( ts -- d ) " " split first ;
- : date-for-timestamp ( ts -- d ) " " split second ;
- ! : hour-for-timestamp ( ts -- d ) " " split third ;
- ! : for-clocking-in ( fn -- l ) utf8 file-lines ;
- ! "/tmp/times.txt" utf8 file-lines [ " " split ] map [ first "in" = ] ;
- : base-for-date ( h l -- h ) date-for-timestamp swap at unix-1970 or ;
- : seconds-for ( l -- ts ) " " split 1 tail " " join ymdhms>timestamp ;
- : process-line ( h l -- h x ) dup [ base-for-date ] [ seconds-for ] [ in/out-for-timestamp "in" = [ time- ] [ time+ ] if ] tri ;
- H{ } clone "in 2017-03-19 00:00:00" [ base-for-date ] [ seconds-for ] [ in/out-for-timestamp "in" = [ time- ] [ time+ ] if ] tri
- H{ } clone "in 2017-03-19 00:00:00" process-line
- "in 2017-03-19 00:00:00" seconds-for
- : foo ( x -- x ) " " split first ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement