2013-06-24 23:41:59 +00:00
|
|
|
|
'use strict';
|
|
|
|
|
define(
|
|
|
|
|
[
|
|
|
|
|
'backbone',
|
2013-07-17 06:23:44 +00:00
|
|
|
|
'moment',
|
2013-06-24 23:41:59 +00:00
|
|
|
|
'Series/EpisodeModel'
|
2013-07-17 06:23:44 +00:00
|
|
|
|
], function (Backbone, Moment, EpisodeModel) {
|
2013-06-24 23:41:59 +00:00
|
|
|
|
return Backbone.Collection.extend({
|
|
|
|
|
url : window.ApiRoot + '/calendar',
|
|
|
|
|
model: EpisodeModel,
|
2013-06-06 03:03:04 +00:00
|
|
|
|
|
2013-07-01 18:25:06 +00:00
|
|
|
|
comparator: function (model1, model2) {
|
2013-07-24 05:28:06 +00:00
|
|
|
|
var airDate1 = model1.get('airDateUtc');
|
2013-07-17 06:23:44 +00:00
|
|
|
|
var date1 = Moment(airDate1);
|
|
|
|
|
var time1 = date1.unix();
|
2013-07-01 18:25:06 +00:00
|
|
|
|
|
2013-07-24 05:28:06 +00:00
|
|
|
|
var airDate2 = model2.get('airDateUtc');
|
2013-07-17 06:23:44 +00:00
|
|
|
|
var date2 = Moment(airDate2);
|
|
|
|
|
var time2 = date2.unix();
|
2013-07-01 18:25:06 +00:00
|
|
|
|
|
|
|
|
|
if (time1 < time2){
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (time1 > time2){
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
2013-06-24 23:41:59 +00:00
|
|
|
|
}
|
|
|
|
|
});
|
2013-02-23 17:42:15 +00:00
|
|
|
|
});
|