Skip to content

Instantly share code, notes, and snippets.

@cspanring
Created August 19, 2014 15:46
Show Gist options
  • Select an option

  • Save cspanring/c25b91fa7d64a24521a4 to your computer and use it in GitHub Desktop.

Select an option

Save cspanring/c25b91fa7d64a24521a4 to your computer and use it in GitHub Desktop.
Ember Data Isodate Transform (requires moment.js)
import DS from 'ember-data';
export default DS.Transform.extend({
deserialize: function(serialized) {
if (serialized) {
return moment(serialized).toDate();
}
return serialized;
},
serialize: function(deserialized) {
if (deserialized) {
return moment(deserialized).format('YYYY-MM-DD');
}
return deserialized;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment