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

Fix some ILM Timezone Madness #1258

Merged
merged 4 commits into from
Dec 21, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/components/dashboard-agenda.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ export default Component.extend({
init() {
this._super(...arguments);

const fromTimeStamp = moment().hour(0).minute(0).unix();
const toTimeStamp = moment().hour(23).minute(59).add(30, 'days').unix();
const fromTimeStamp = moment.utc().hour(0).minute(0).unix();
const toTimeStamp = moment.utc().hour(23).minute(59).add(30, 'days').unix();

this.setProperties({ fromTimeStamp, toTimeStamp });
},
Expand Down
4 changes: 2 additions & 2 deletions app/components/dashboard-calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ export default Component.extend({
this.set('selectedCourses', []);
}),
fromTimeStamp: computed('selectedDate', 'selectedView', function(){
return moment(this.get('selectedDate')).startOf(this.get('selectedView')).unix();
return moment.utc(this.get('selectedDate')).startOf(this.get('selectedView')).unix();
}),
toTimeStamp: computed('selectedDate', 'selectedView', function(){
return moment(this.get('selectedDate')).endOf(this.get('selectedView')).unix();
return moment.utc(this.get('selectedDate')).endOf(this.get('selectedView')).unix();
}),
calendarDate: momentFormat('selectedDate', 'YYYY-MM-DD'),
ourEvents: computed('mySchedule', 'fromTimeStamp', 'toTimeStamp', 'selectedSchool', 'selectedView', function(){
Expand Down
25 changes: 25 additions & 0 deletions app/serializers/ilm-session.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import DS from 'ember-data';
import moment from 'moment';

const { RESTSerializer } = DS;

export default RESTSerializer.extend({
isNewSerializerAPI: true,
serialize(snapshot, options) {
let json = this._super(snapshot, options);
let dueDate = moment(json.dueDate);
json.dueDate = dueDate.format('YYYY-MM-DD');

//don't persist this, it is handled by the server
delete json.updatedAt;

return json;
},
normalize(modelClass, resourceHash, prop){
let dueDate = moment.utc(resourceHash.dueDate).format('YYYY-MM-DD');
let localDueDate = moment(dueDate, 'YYYY-MM-DD');
resourceHash.dueDate = localDueDate.format();

return this._super(modelClass, resourceHash, prop);
}
});
11 changes: 9 additions & 2 deletions app/services/school-events.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,18 @@ export default Ember.Service.extend(EventMixin, {
var url = '/' + config.adapterNamespace + '/schoolevents/' +
schoolId + '?from=' + from + '&to=' + to;
ajax(url).then(data => {
let events = data.events.sortBy('startDate').map(event => {
let events = data.events.map(event => {
event.slug = this.getSlugForEvent(event);
if (event.ilmSession) {
let startDate = moment(moment.utc(event.startDate).format('YYYYMMDD'), 'YYYYMMDD').hour(17).minute(0).second(0);
let endDate = moment(moment.utc(event.endDate).format('YYYYMMDD'), 'YYYYMMDD').hour(17).minute(15).second(0);
event.startDate = startDate.format();
event.endDate = endDate.format();

}

return event;
});
}).sortBy('startDate');

deferred.resolve(events);
});
Expand Down
11 changes: 9 additions & 2 deletions app/services/user-events.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,18 @@ export default Ember.Service.extend(EventMixin, {
var url = '/' + config.adapterNamespace + '/userevents/' +
user.get('id') + '?from=' + from + '&to=' + to;
ajax(url).then(data => {
let events = data.userEvents.sortBy('startDate').map(event => {
let events = data.userEvents.map(event => {
event.slug = this.getSlugForEvent(event);
if (event.ilmSession) {
let startDate = moment(moment.utc(event.startDate).format('YYYYMMDD'), 'YYYYMMDD').hour(17).minute(0).second(0);
let endDate = moment(moment.utc(event.endDate).format('YYYYMMDD'), 'YYYYMMDD').hour(17).minute(15).second(0);
event.startDate = startDate.format();
event.endDate = endDate.format();

}

return event;
});
}).sortBy('startDate');

deferred.resolve(events);
});
Expand Down
21 changes: 21 additions & 0 deletions tests/unit/serializers/ilm-session-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { moduleForModel, test } from 'ember-qunit';

moduleForModel('ilm-session', 'Unit | Serializer | ilm session', {
// Specify the other units that are required for this test.
needs: [
'model:session',
'model:learner-group',
'model:instructor-group',
'model:user',
'serializer:ilm-session'
]
});

// Replace this with your real tests.
test('it serializes records', function(assert) {
let record = this.subject();

let serializedRecord = record.serialize();

assert.ok(serializedRecord);
});