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

add toDate toDateTime in filter #46

Closed
guileen opened this issue Nov 19, 2011 · 4 comments
Closed

add toDate toDateTime in filter #46

guileen opened this issue Nov 19, 2011 · 4 comments

Comments

@guileen
Copy link

guileen commented Nov 19, 2011

I just get here, and view the source code, great work, but just one question, why not put toDate, toDateTime in Filter?

@chriso
Copy link
Collaborator

chriso commented Nov 20, 2011

As in unix timestamp to a Javascript Date object? Or a full blown strptime implementation? A unix timestamp to Date object would be easy:

var toDate = function (timestamp) {
    return new Date(parseInt(timestamp, 10) * 1000);
}

@guileen
Copy link
Author

guileen commented Nov 20, 2011

Thanks. it is a problem for the format of date.

I just create a project node-iform, base on node-validator. I hope you can take a look that.

@guileen guileen closed this as completed Nov 20, 2011
@chriso
Copy link
Collaborator

chriso commented Nov 20, 2011

I'd say it's outside the scope of the library, but you can have a look at moment.js which might have the date parsing/formatting functionality you're looking for. I'll take a look at node-iform - nice to see validator out in the wild.

@chesles
Copy link
Contributor

chesles commented Jul 23, 2012

A simple "toDate" that calls new Date(this.str) would be handy in Filter. Date.parse or new Date in node already handle some parsing:

> new Date('Jan 27, 2011')
Thu Jan 27 2011 00:00:00 GMT-0700 (MST)
> new Date(1296111600000)
Thu Jan 27 2011 00:00:00 GMT-0700 (MST)

Maybe a quick check to see if the input is all-numeric (as in the case of "1296111600000"), since passing that as a string returns an Invalid Date.

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

No branches or pull requests

3 participants