From: Siraaj Khandkar Date: Sun, 21 Mar 2021 15:50:26 +0000 (-0400) Subject: Remove dependency on rfc3339-old X-Git-Tag: 0.11.0 X-Git-Url: https://git.xandkar.net/?a=commitdiff_plain;h=f9d1c7feffe08f79884856d47eb0f8aa3833d06d;p=tt.git Remove dependency on rfc3339-old --- diff --git a/info.rkt b/info.rkt index 869e094..232640e 100644 --- a/info.rkt +++ b/info.rkt @@ -6,11 +6,11 @@ (define pkg-desc "twtxt client") (define version - "0.10.0") + "0.11.0") (define pkg-authors '("Siraaj Khandkar ")) (define deps - '("base" "rfc3339-old")) + '("base")) (define racket-launcher-names '("tt")) (define racket-launcher-libraries diff --git a/tt.rkt b/tt.rkt index 42153ec..f7731c4 100644 --- a/tt.rkt +++ b/tt.rkt @@ -8,8 +8,6 @@ net/url-string net/url-structs) -(require rfc3339-old) - (module+ test (require rackunit)) @@ -90,10 +88,9 @@ (date->string (seconds->date [msg-ts_epoch msg]) #t)) nick uri color text)]))))) -; TODO Implement rfc3339->epoch and remove dependency on rfc3339-old - (define str->msg - (let ([re (pregexp "^([0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}(:[0-9]{2})?)(\\.[0-9]+)?([^\\s\t]*)[\\s\t]+(.*)$")]) + ; TODO Split parsing into 2 stages: 1) line->list; 2) rfc3339->epoch. + (let ([re (pregexp "^(([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2})(:([0-9]{2}))?)(\\.[0-9]+)?([^\\s\t]*)[\\s\t]+(.*)$")]) (λ (nick uri str) (with-handlers* ([exn:fail? @@ -103,18 +100,16 @@ str nick (url->string uri) e) #f)]) (match (regexp-match re str) - [(list _wholething ts s _fractional tz text) + [(list _wholething ts yyyy mm dd HH MM _:SS SS _f tz text) (let* - ([ts_rfc3339 (string-append ts (if s "" ":00") (if tz tz ""))] - [t (string->rfc3339-record ts_rfc3339)] - [s (rfc3339-record:second t)] ; TODO handle tz offset - [ts_epoch (find-seconds [if s s 0] - [rfc3339-record:minute t] - [rfc3339-record:hour t] - [rfc3339-record:mday t] - [rfc3339-record:month t] - [rfc3339-record:year t])]) + ([ts_rfc3339 (string-append ts (if SS "" ":00") (if tz tz ""))] + [ts_epoch (find-seconds (if SS (string->number SS) 0) + (string->number MM) + (string->number HH) + (string->number dd) + (string->number mm) + (string->number yyyy))]) (msg ts_epoch ts_rfc3339 nick uri text))] [_ (log-debug "Non-msg line from nick:~a, line:~a" nick str)