-
Notifications
You must be signed in to change notification settings - Fork 988
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
Dev: Add JS date lib by Matt Kruse (javascripttoolbox.com) #170
Conversation
Mfaber what is the use case for parsing the date in javascript?
|
Sam: mostly date conversion in EM for properly handling validation and relevance of all the different date/time formats users work with. In LEMval() I do this at the moment with the parse function of the datetimepicker but this is really unsatisfactory. Incomplete dates cause problems (only a year or only year and a month) as are mixed date/time formats. |
Yii has built in datetime validators that support different formats. Could we use that? I am not against the library; for 2.10 we will redo that part anyway so a
|
But Yii is PHP, right? EM needs JS to do conversions, validation etc on the fly (same page)... |
Yii does both
|
That'd be great! This is the function I need: CDateTimeParser (http://www.yiiframework.com/doc/api/1.1/CDateTimeParser). And I already used it to do conversions in PHP...but how do I get to an equivalent in JS... |
Search for clientValidate that function returns javascript for clientside
|
Don't test a lot but what for http://phpjs.org/functions/date/ and http://phpjs.org/functions/strtotime/ ? I think a lot of dev use phpjs and we can fix some bug of LimeSurvey with fixed bug from phpjs ? |
Thanks for your suggestions...really appreciate it! Unfortunately they do not get me where I want... SamMousa: Client validation is unfortunately not implemented for CDateTimeParser...(and for many other Yii-functions it seems)... Shnoulle: Had checked phpjs already, in fact I rewrote half of strtotime() at phpjs myself :). date() is the other way around (timestamp->string) and strtotime() works very well with a handful of date formats but does not accept format strings. |
@mfaber, looks fine to me - please merge. |
btw, Is there a way to use it and NOT modify it? That would it make alot easier if the lib would have updates in the future. |
I'm afraid there won't be too many updates. This version seems to be around since 2006 :). |
Dev: Add JS date lib by Matt Kruse (javascripttoolbox.com)
@c-schmitz
I am desperately missing a JS function to parse a date string using a format identifier. In PHP no problem but in JS...
I would therefore like to add this small lib (or just one function of it) to LS but was unsure where and how to put it. Hence the pull request. I actually would like to make some minor modifications to it before merging so the format identifiers match those of LS and are most convenient to us.
Can I just modify this lib, put a note in the file that it's been modified and have this in third_party? Sorry if that seems a dumb question...still new to OSS and LS :)