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

Make DS.attr("date") accept a user inputted string as a date #258

Closed
wants to merge 1 commit into from
Closed

Make DS.attr("date") accept a user inputted string as a date #258

wants to merge 1 commit into from

Conversation

bradleypriest
Copy link
Member

Currently you can't set an DS date attribute on a DS.model from a user input as it expects a JS Date object.

I'm not sure if this is the best implementation (should probably handle invalid dates) but now you can set a date in any format the JS Date object accepts.

@joliss
Copy link
Contributor

joliss commented May 17, 2012

I wonder if it's good practice to instantiate Date like that, as opposed to constructing it by manually parsing strings and calling new Date(year, month, day, ...) -- that's what I'm doing at least.

I'd be worried in particular about cross-browser/cross-locale differences in date parsing.

Can somebody with more time-wrangling experience than me please comment if there are cases where this might be useful?

@tchak
Copy link
Member

tchak commented May 17, 2012

We should have a proper ember-date and then use it in ember-data...
I have started some work on a moment wrapper in Ember object, I think it is a good compromise without doing all the ground work all over again.

@bradleypriest
Copy link
Member Author

Sorry guys, I was looking at this all wrong anyway. Because it is stored as a Date object, you can't really use it as a date input field anyway. Gonna go with a custom view, probably with a hidden field for now.

@tchak I've been using your datetime library from https://github.com/capitainetrain/ember-addons/blob/master/packages/ember-datetime/lib/core.js in my app, and it seems to work pretty well, but moment is a great option as well.

@tchak
Copy link
Member

tchak commented May 17, 2012

@bradleypriest the wrapper I was talking about use the same api as Ember.DateTime but the objects are mutable.
Ember.DateTime main issue is that it is un necessary complex because of reuse of Date object to all instances. This is also the reason an instance is not mutable.

As soon as it is ready I will opensource it

@kmiyashiro
Copy link
Contributor

@tchak did you ever opensource the moment wrapper?

@tchak
Copy link
Member

tchak commented Jul 19, 2013

@kmiyashiro It is funny you asking, I am working on it right now. It is not finished yep. Hopefully soon.

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

Successfully merging this pull request may close these issues.

4 participants