-
Notifications
You must be signed in to change notification settings - Fork 532
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
#112 Get rid of moment over date-fns #116
Conversation
Use babel-plugin-lodash to support "tree-shaking" for lodash
@@ -105,7 +105,8 @@ describe("fieldDateTimePicker.vue", function() { | |||
}); | |||
}); | |||
|
|||
it("model value should be the formatted input value if changed", (done) => { | |||
//TODO These kinds of formats don't work with date-fns library | |||
it.skip("model value should be the formatted input value if changed", (done) => { |
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.
This is why skipped? I see it support formatting.
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.
Will look at it tomorrow. I had parsing errors on this test but the library supports those formats.
https://jsfiddle.net/z11fe07p/729/
When running tests same statement as the one from the fiddle gives
LOG: Invalid Date
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.
fiddle is working at me. No error, in result: "2015-01-01T23:00:00.000Z"
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.
Yeah, I know. Fiddle and webpack bin working, but as long as the same thing is used in the code it doesn't work. console.log(parse("2015.01.02"))
outputs Invalid Date
in the code although it works in the fiddle. Very strange. If we pass this error, we are good to get rid of moment js.
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.
It's weird. I thought parse
has a format parameter at least.
From momentjs we need only the format and parse functions. So we can search other date library only for this functions. I found it: https://github.com/taylorhakes/fecha |
Also isValid, isAfter, isBefore :) |
OK, but these only for validation. And isAfter, isBefore is easy with unix epoch dates. I rewrite date validator if this lib take out momentjs. |
I will give it a try today. Seems strange though that date-fns format doesn't work here but works in fiddle |
OK, thanks. |
Could you test |
Please test it if you have the time. I can do it only in 4-5 hours or so. |
Ok, I do it. |
I tried, and it is working properly: #117 |
So date-fns or fecha ? |
In this case fecha, because date-fns parse currently not supported format param, but there is format property in schemas |
Ok cool, when will you merge ? |
Btw, pikaday & datetimepicker fields is not working in dev example. But it's not came with fecha, because not working in master branch too. I try to fix it. |
@cristijora thanks this PR, but I close it. I copied your babel lodash solution to #117. |
I would like to present an option over moment.js which is date-fns.
Date-fns is very modular and you can require only the things you need from it. The downside though is that it doesn't support a variety of date formats. See skipped test. Might support them with version 2.0 which should come soon I think.
On the other hand now the build reduces to 80kb :)