-
-
Notifications
You must be signed in to change notification settings - Fork 236
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
dateFormat fails if no time present (Partial Fix inside) #96
Comments
Sure no problemo! The format I noticed this with was the default sql date format (yyyy-mm-dd). While I was testing I always got this error: I then added the !isNaN line and did some tests. Here are the results: Code:
Output:
At first I tried appending "00:00:00.000" to the Date strings before formatting them, but that seemed to be unreliable as it failed with "undefined" often. But yeah, it works right now for what I need it for (yyyy-mm-dd!). Hope that could help a little bit. Sorry if that wasn't legible in some way, I'm off to bed now :) |
Some more testing (day/month above 12 to differenciate formats):
|
So I'm working on a project where I was using dateFormat for formatting various kinds of dates client-sided. It worked great until I noticed dates that didn't have time ("2016-06-11") would return an error (IndexOf is undefined) and not format the date. After a quick snoop around I figured it was because the calculations didn't return a Number, so it failed to run the parseTime function.
Here's the problematic code (Line 180 in current dist):
Add a simple line to fix it:
After that change, you can now use date-only formats with the plugin. Can someone confirm this was an issue or if time-less dates are not intended.
The only issue I am getting now is reverse-year formats, where the year is at the end of the format such as "11-05-2016" would return an invalid date. Any ideas?
The text was updated successfully, but these errors were encountered: