flipstone / json-fleece

Extensible JSON Schemas for Haskell
MIT License
2 stars 1 forks source link

Custom day formatting #14

Closed ysangkok closed 1 year ago

ysangkok commented 1 year ago

Many people are using custom day formats. This allows for conveniently specifying these formats, also with code gen.

This does of course allow for specifying schemas that don't round trip:

> stack repl --package json-fleece-aeson
ghci> :m +TestCases.Types.CustomDateFormat
ghci> :m +Fleece.Aeson
ghci> :set -XOverloadedStrings
ghci> decode customDateFormatSchema  "\"12/31/49\""
Right (CustomDateFormat 2049-12-31)
ghci> encode customDateFormatSchema  (CustomDateFormat (Time.fromGregorian 2049 12 31))
"\"12/31/49\""
ghci> encode customDateFormatSchema  (CustomDateFormat (Time.fromGregorian 1949 12 31))
"\"12/31/49\""