matthewmueller / matthewmueller/date
Why are you returning a default date when the supplied input is invalid?
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 1.5k
- Forks
- 85
- PR merge metrics
- No merged PRs in 30d
Description
This is such a basic piece of functionality and it makes this package unusable in cases where input must be validated. So what is the thinking here and why has date.js been created in a way that faulty input like this:
date("blah")
actually returns a valid date?
In use cases where an end user is trying to run a search for a time/date range it isn't desired to have every failed parsing default to now/today.
So why is it built this way and why is there no configuration option to turn that off? If a bad date string is provided I wouldn't personally want any value returned.
It's very easy for consumers of date.js to do this if they always want a date value:
function parseDate(val) {
return date(val) || date("now")
}
But there isn't a way for us to ensure that invalid date values are rejected.
Can this be fixed?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading date.js and tracing how the input date("blah") is handled. Check whether invalid input is covered by existing tests, then define and verify behavior in which faulty date strings do not produce a valid default date.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100