-
Notifications
You must be signed in to change notification settings - Fork 48
Date/time overhaul #34
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
Conversation
I like the split, but I wonder why the dependencies aren't reversed, with the smaller, lower-level |
Eventually I would prefer this library not to use any FFI, so I think the dependencies are better this way around - ideally the datetime library should be backend agnostic, and pulling |
That makes sense. In that case, I'll review this a bit more later tonight. |
I re-included the locale stuff - it seems reasonable to provide a method of representing localised date/time values, and I've updated |
foreign import jsDateMethod :: forall a. Fn2 String JSDate a | ||
|
||
foreign import strictJsDate :: Fn3 (forall a. a -> Maybe a) (forall a. Maybe a) String (Maybe JSDate) | ||
show (Date y m d) = "(Date " <> show y <> " " <> show m <> " " <> show d <> ")" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use gShow
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could certainly do that, for pretty much all the Show
instances actually. Is that preferable in this case then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think core libraries should use the generic implementations because they are much slower; and the libraries don't change very often (at least in theory 😆) so the overhead of manually writing and maintaining the instances is much lower.
Looks great! Sorry for the delayed review. |
No problem! It's a pretty big changeset. I'll merge and release this after we decide on whether |
I'll add a comment in the code about the seemingly arbitrary year bounds too actually. |
@paf31 is this good to go then? |
I think so! 🚢 it. |
Ok, I think this is ready now.
It's a fully PureScript based representation, but we privately hand off some logic to the JS date stuff, for now at least.
I didn't include
Locale
orHour12
in here in the end, to keep this library down to just the types needed to represent and manipulate date/times. We will probably want to add some more operations over time too, but I think this is a reasonable starting place.The other parts of datetime are now in two other libraries -
purescript-now
for fetching the current date, andpurescript-js-date
for theJSDate
type and general interop. We'll probably also want to introduce a library for convenient parsing and printing of date formats fairly soon too.