On 4/27/20, Tim Hanson <[email protected]> wrote:
>
> I thought I'd check here:
> - does this seem like a reasonable idea?
> - is mine an unusual use case and most folks know what format to expect and
> the exception approach is fine?

I've written code like this before and used it in a contract.

```
(define (iso8601-string? x)
  (and (string? x)
       (with-handlers ((exn:gregor:parse? (lambda (e) #false)))
         (date? (iso8601->date x)))))

(module+ test
  (test-case "iso8601-string?"
    (check-pred iso8601-string? "2018-10-02T01:00:00")))
```

I haven't had to worry about its performance; it was fast enough!

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAFUu9R4G-VprXwSq4RC1mjOFK9hOiXAmLyX0SHoX2uzx5HzVNA%40mail.gmail.com.

Reply via email to