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

Dev: Add JS date lib by Matt Kruse (javascripttoolbox.com) #170

Merged
merged 1 commit into from
Feb 8, 2014

Conversation

mfaber
Copy link
Contributor

@mfaber mfaber commented Feb 8, 2014

@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 :)

@SamMousa
Copy link
Contributor

SamMousa commented Feb 8, 2014

Mfaber what is the use case for parsing the date in javascript?
On Feb 8, 2014 4:48 PM, "mfaber" notifications@github.com wrote:

@c-schmitz https://github.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 :)

You can merge this Pull Request by running

git pull https://github.com/mfaber/LimeSurvey datelib

Or view, comment on, or merge it at:

#170
Commit Summary

  • Dev: Add JS date lib by Matt Kruse (javascripttoolbox.com)

File Changes

Patch Links:


Reply to this email directly or view it on GitHubhttps://github.com//pull/170
.

@mfaber
Copy link
Contributor Author

mfaber commented Feb 8, 2014

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.

@SamMousa
Copy link
Contributor

SamMousa commented Feb 8, 2014

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
quick fix is ok imo.
On Feb 8, 2014 5:48 PM, "mfaber" notifications@github.com wrote:

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.


Reply to this email directly or view it on GitHubhttps://github.com//pull/170#issuecomment-34548728
.

@mfaber
Copy link
Contributor Author

mfaber commented Feb 8, 2014

But Yii is PHP, right? EM needs JS to do conversions, validation etc on the fly (same page)...

@SamMousa
Copy link
Contributor

SamMousa commented Feb 8, 2014

Yii does both
http://www.yiiframework.com/doc/api/1.1/CDateValidator
On Feb 8, 2014 6:45 PM, "mfaber" notifications@github.com wrote:

But Yii is PHP, right? EM needs JS to do conversions, validation etc on
the fly (same page)...


Reply to this email directly or view it on GitHubhttps://github.com//pull/170#issuecomment-34550365
.

@mfaber
Copy link
Contributor Author

mfaber commented Feb 8, 2014

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...

@SamMousa
Copy link
Contributor

SamMousa commented Feb 8, 2014

Search for clientValidate that function returns javascript for clientside
validation afaik
On Feb 8, 2014 7:06 PM, "mfaber" notifications@github.com wrote:

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...


Reply to this email directly or view it on GitHubhttps://github.com//pull/170#issuecomment-34550952
.

@Shnoulle
Copy link
Collaborator

Shnoulle commented Feb 8, 2014

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 ?

@mfaber
Copy link
Contributor Author

mfaber commented Feb 8, 2014

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.

@c-schmitz
Copy link
Contributor

@mfaber, looks fine to me - please merge.

@c-schmitz
Copy link
Contributor

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.

@mfaber
Copy link
Contributor Author

mfaber commented Feb 8, 2014

I'm afraid there won't be too many updates. This version seems to be around since 2006 :).
There are many other specialised js date libs out there because dates in js are just a mess. However these pack tons of other function and are much larger....
I'll merge the original lib, make modifications in a separate commit and document the changes in the header...

mfaber added a commit that referenced this pull request Feb 8, 2014
Dev: Add JS date lib by Matt Kruse (javascripttoolbox.com)
@mfaber mfaber merged commit 16077d9 into LimeSurvey:master Feb 8, 2014
@mfaber mfaber deleted the datelib branch February 8, 2014 20:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants