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

Y-m-d #34

Merged
merged 6 commits into from
Feb 23, 2014
Merged

Y-m-d #34

merged 6 commits into from
Feb 23, 2014

Conversation

bartaakos
Copy link
Contributor

I added support for Y-m-d (dashed) date format for parseDateString matchers

@hilios
Copy link
Owner

hilios commented Feb 3, 2014

Thank you for your collaboration, before I dd the merge, please add proper testing to your PR (do the changes on your branch and do a push to update in here).

If you don't know how to start please look at https://github.com/hilios/jQuery.countdown/blob/master/test/countdown_test.js#L237

@bartaakos
Copy link
Contributor Author

Is this what you meant? :)

@hilios
Copy link
Owner

hilios commented Feb 3, 2014

Yes it is goo job, but something went wrong, because the test are failing....

https://travis-ci.org/hilios/jQuery.countdown/builds/18123302

@bartaakos
Copy link
Contributor Author

Do you have any idea why isn't it working? As I can see the regexp matches the given strings and it is working fine in my implementation. :S

@hilios
Copy link
Owner

hilios commented Feb 4, 2014

Indeed, but seens the PhantomJS (a Webkit headless browser) can't parse the
Y-m-d date format ...

2014-02-03 Barta Ákos notifications@github.com:

Do you have any idea why isn't it working? As I can see the regexp matches
the given strings and it is working fine in my implementation. :S


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

Edson Hilios
+55 11 999-283-107
http://edson.hilios.com.br http://www.edsonhilios.com.br

@hilios
Copy link
Owner

hilios commented Feb 23, 2014

Hey man, did you gave up on this?

I was looking that at this issue and this is the actual behaviour on Qt Webkit (used in Chrome Canary, Safari, iOS between others). So the approval of this PR would cause the script breaks in browsers that use it.

But fear not, your request is still possible you just need to add a RegExp to replace the dash char - to a slash /. I will add some comments to your source code to be clear.

What you think @bartaakos? Can we finish this PR ;)

@@ -31,7 +31,7 @@
var instances = [], matchers = [];
matchers.push(/^[0-9]*$/.source);
matchers.push(/([0-9]{1,2}\/){2}[0-9]{4}( [0-9]{1,2}(:[0-9]{2}){2})?/.source);
matchers.push(/[0-9]{4}(\/[0-9]{1,2}){2}( [0-9]{1,2}(:[0-9]{2}){2})?/.source);
matchers.push(/[0-9]{4}([\/\-][0-9]{1,2}){2}( [0-9]{1,2}(:[0-9]{2}){2})?/.source);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At line #29 you could just add a conditional statement in parseDate function to replace dashes to slashes, simple like:

if(String(dateString).match(matchers)) {
    // If looks like a millisecond value cast to number before 
    // final casting (Thanks to @msigley)
    if(String(dateString).match(/^[0-9]*$/)) {
        dateString = Number(dateString);
    }
    // Replace dashes to slashes
    if(String(dateString).match(/^[0-9]*$/)) {
        dateString = dateString.replace(/\-/g, '/');
    }
    return new Date(dateString);
}

@bartaakos
Copy link
Contributor Author

Hi,

Sorry for not replying for ages :/

So basicly you say, that we can get a workaround by simply replacing - to /. It's fine by me, thank you :)

@hilios
Copy link
Owner

hilios commented Feb 23, 2014

That's it @bartaakos, if everything is green in Travis this PR will LGTM and will be merge right away!

@bartaakos
Copy link
Contributor Author

I just got back to my computer and pushed in the changes :)

@bartaakos
Copy link
Contributor Author

Finally :)

hilios added a commit that referenced this pull request Feb 23, 2014
Add support to SQL dates Y-m-d
@hilios hilios merged commit d8cccc9 into hilios:master Feb 23, 2014
@hilios
Copy link
Owner

hilios commented Feb 23, 2014

Great job, you are now a TDD master!!!

@hilios hilios added this to the 2.0.3 milestone Feb 23, 2014
@hilios hilios added the feature label Feb 23, 2014
@bartaakos
Copy link
Contributor Author

Well I stayed quite long in the red but.. :D
Thank you anyway :)

@bartaakos
Copy link
Contributor Author

Oh btw I didn't update the .min file because I didn't know which minifier did you use.

@hilios
Copy link
Owner

hilios commented Feb 23, 2014

It's all bundled in the grunt tasks. If you look at the Gruntfile.js line #50 you will discover that I use UglifyJS to generate both production and development versions.

A little bit bellow at line #106 you can see that I have a grunt build task to automatically test everything, compile and generate a zip file to distribute.

@hilios
Copy link
Owner

hilios commented Feb 23, 2014

But you don't need to worry by now, once I will do a proper release with tag v2.0.3 when complete all planned changes, I already assigned this PR to that release.

@bartaakos
Copy link
Contributor Author

Okay, cool :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants