Skip to content

Instantly share code, notes, and snippets.

@GRardB
Created April 16, 2016 22:18
Show Gist options
  • Save GRardB/4d3edfaec64c69c794dcfc61aa590044 to your computer and use it in GitHub Desktop.
Save GRardB/4d3edfaec64c69c794dcfc61aa590044 to your computer and use it in GitHub Desktop.
// app/transforms/utc.js
import moment from 'moment';
import Transform from 'ember-data/transform';
export default Transform.extend({
deserialize(serialized) {
const date = serialized.split('T')[0];
return moment(date).toDate();
},
serialize(deserialized) {
const date = moment(deserialized).format('YYYY-MM-DD');
return moment.utc(date).toDate();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment