-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update readme/docs to de-emphasise usage of string formats #22
Comments
Not saying we shouldn't support the string formats - they do have their uses, just not for formatters that are statically defined in PureScript code. |
@safareli pointed out that some formats are invalid (as they'd parse ambiguously) We may do something like this: https://gist.github.com/garyb/1c4fda54c630e59e609c1f04058e5ac8 so we can validate formats at the type level. |
I think we would need to split formats, like have separate DateFormat and TimeFormat and use them in DateTimeFormat: newtype DateFormat = DateFormat (List DateCommand)
data DateCommand
= YearFull
| YearTwoDigits
| YearAbsolute
| Placeholder String
...
newtype TimeFormat = TimeFormat (List TimeCommand)
data TimeCommand
= Hours24
| Hours12
| Meridiem
| Placeholder String
...
data DateTimeCommand
= Date DateFormat
| Time TimeFormat
| Placeholder String
newtype DateTimeFormat = DateTimeFormat (List DateTimeCommand) |
If we merge #26 then we would not be able to build datetime parser using date and time parsers because of "day shift". |
We and I'm sure others have a lot of code that looks like this sort of thing at the moment:
timeFormat = unsafePartial fromRight $ parseFormatString "HH:mm:ss"
Which is actually quite silly, when it's actually easier, safer, and generally better all round to just construct the format directly:
😆
As another advantage of that is
Hours24
is better self-documentation than remembering"HH
" vs"hh"
forHours24
vsHours12
too, etc.The text was updated successfully, but these errors were encountered: