calendar.parser,robots: hhmm>timestamp -> hhmm>duration
Better to parse it as a duration because it is not a valid timestamp.char-rename
parent
2895d5e095
commit
3bbc784fad
|
@ -44,6 +44,13 @@ IN: calendar.parser.tests
|
|||
time- 1 seconds before?
|
||||
] unit-test
|
||||
|
||||
! hhmm>duration
|
||||
{
|
||||
T{ duration { hour 10 } { minute 20 } }
|
||||
} [
|
||||
"1020" hhmm>duration
|
||||
] unit-test
|
||||
|
||||
! parse-rfc822-gmt-offset
|
||||
{ T{ duration f 0 0 0 0 0 0 } } [
|
||||
"GMT" parse-rfc822-gmt-offset
|
||||
|
|
|
@ -27,11 +27,6 @@ ERROR: invalid-timestamp-format ;
|
|||
|
||||
: read-sp ( -- token ) " " read-token ;
|
||||
|
||||
: hhmm>timestamp ( hhmm -- timestamp )
|
||||
[
|
||||
0 0 0 read-00 read-00 0 instant <timestamp>
|
||||
] with-string-reader ;
|
||||
|
||||
: signed-gmt-offset ( dt ch -- dt' )
|
||||
{ { CHAR: + [ 1 ] } { CHAR: - [ -1 ] } } case time* ;
|
||||
|
||||
|
@ -181,3 +176,7 @@ MACRO: attempt-all-quots ( quots -- quot )
|
|||
|
||||
: ymd>timestamp ( str -- timestamp )
|
||||
[ (ymd>timestamp) ] with-string-reader ;
|
||||
|
||||
! Duration parsing
|
||||
: hhmm>duration ( hhmm -- duration )
|
||||
[ instant read-00 >>hour read-00 >>minute ] with-string-reader ;
|
||||
|
|
|
@ -26,8 +26,8 @@ IN: robots.tests
|
|||
}
|
||||
{ visit-time
|
||||
{
|
||||
T{ timestamp { hour 2 } }
|
||||
T{ timestamp { hour 5 } }
|
||||
T{ duration { hour 2 } }
|
||||
T{ duration { hour 5 } }
|
||||
}
|
||||
}
|
||||
{ request-rate 1 }
|
||||
|
|
|
@ -63,7 +63,7 @@ visit-time request-rate crawl-delay unknowns ;
|
|||
{ "crawl-delay" [ string>number >>crawl-delay ] }
|
||||
{ "request-rate" [ string>number >>request-rate ] }
|
||||
{
|
||||
"visit-time" [ "-" split1 [ hhmm>timestamp ] bi@ 2array
|
||||
"visit-time" [ "-" split1 [ hhmm>duration ] bi@ 2array
|
||||
>>visit-time
|
||||
] }
|
||||
[ pick unknowns>> push-at ]
|
||||
|
|
Loading…
Reference in New Issue