mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
Merge pull request #2889 from novaugust/post-model-dates
Changed ember models to use moment for dates
This commit is contained in:
commit
46cabf35fc
3 changed files with 22 additions and 6 deletions
|
@ -12,11 +12,11 @@ var Post = DS.Model.extend({
|
|||
meta_title: DS.attr('string'),
|
||||
meta_description: DS.attr('string'),
|
||||
author: DS.belongsTo('user', { async: true }),
|
||||
created_at: DS.attr('date'),
|
||||
created_at: DS.attr('moment-date'),
|
||||
created_by: DS.belongsTo('user', { async: true }),
|
||||
updated_at: DS.attr('date'),
|
||||
updated_at: DS.attr('moment-date'),
|
||||
updated_by: DS.belongsTo('user', { async: true }),
|
||||
published_at: DS.attr('date'),
|
||||
published_at: DS.attr('moment-date'),
|
||||
published_by: DS.belongsTo('user', { async: true }),
|
||||
tags: DS.hasMany('tag', { async: true }),
|
||||
|
||||
|
|
|
@ -14,10 +14,10 @@ var User = DS.Model.extend({
|
|||
language: DS.attr('string'),
|
||||
meta_title: DS.attr('string'),
|
||||
meta_description: DS.attr('string'),
|
||||
last_login: DS.attr('date'),
|
||||
created_at: DS.attr('date'),
|
||||
last_login: DS.attr('moment-date'),
|
||||
created_at: DS.attr('moment-date'),
|
||||
created_by: DS.attr('number'),
|
||||
updated_at: DS.attr('date'),
|
||||
updated_at: DS.attr('moment-date'),
|
||||
updated_by: DS.attr('number'),
|
||||
|
||||
isSignedIn: Ember.computed.bool('id'),
|
||||
|
|
16
core/client/transforms/moment-date.js
Normal file
16
core/client/transforms/moment-date.js
Normal file
|
@ -0,0 +1,16 @@
|
|||
/* global moment */
|
||||
var MomentDate = DS.Transform.extend({
|
||||
deserialize: function (serialized) {
|
||||
if (serialized) {
|
||||
return moment(serialized);
|
||||
}
|
||||
return serialized;
|
||||
},
|
||||
serialize: function (deserialized) {
|
||||
if (deserialized) {
|
||||
return moment(deserialized).toDate();
|
||||
}
|
||||
return deserialized;
|
||||
}
|
||||
});
|
||||
export default MomentDate;
|
Loading…
Add table
Reference in a new issue