Skip to content
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

Expose fromCalendarParts #26

Open
stephengoldbaum opened this issue Dec 24, 2020 · 3 comments
Open

Expose fromCalendarParts #26

stephengoldbaum opened this issue Dec 24, 2020 · 3 comments

Comments

@stephengoldbaum
Copy link

Is there a reason not to expose useful functions like fromCalendarParts that can fail with Result? They would be useful.

@justinmimbs
Copy link
Owner

Hi Stephen,

I agree; it would be useful to expose something for date validation.

There are currently three create-date functions that don't fail on out-of-range values (from[Calendar|Week|Ordinal]Date), and it seems overkill to expose strict versions of all three. I'm guessing a common validation use case is to receive three numbers (year, month, and day) and need to validate them. So exposing fromCalendarParts might be enough.

Alternatively, we could expose a function like isValidYearMonthDay : Int -> Int -> Int -> Bool and keep validation separate from creation.

I know @cmditch wanted to expose some helper functions, I think for the purpose of validating date parts like this.

Any thoughts on a nice API for this based on your use cases?

Thanks,

Justin

@stephengoldbaum
Copy link
Author

Hi Justin,

Either of those could work. My thinking with fromCalendarParts is that it already behaves consistently with date libraries from .NET and Java. So partly I want that cross platform consistency and partly it is a more predictable and understandable behavior than rounding out of range values.

I think fromCalendarParts is good from an API perspective.

Thanks,
Stephen

@justinmimbs
Copy link
Owner

Thanks for the feedback, Stephen. That sounds good to me.

Justin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants