Remove dependency on rfc3339-old 0.11.0
authorSiraaj Khandkar <siraaj@khandkar.net>
Sun, 21 Mar 2021 15:50:26 +0000 (11:50 -0400)
committerSiraaj Khandkar <siraaj@khandkar.net>
Sun, 21 Mar 2021 15:50:26 +0000 (11:50 -0400)
info.rkt
tt.rkt

index 869e094..232640e 100644 (file)
--- 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 <siraaj@khandkar.net>"))
 (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 (file)
--- a/tt.rkt
+++ b/tt.rkt
@@ -8,8 +8,6 @@
   net/url-string
   net/url-structs)
 
-(require rfc3339-old)
-
 (module+ test
   (require rackunit))
 
                                   (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?
                  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)
This page took 0.033356 seconds and 4 git commands to generate.