Filter dates with moment.js instead of built-in angular date filter

This commit is contained in:
Marliana Lara 2018-02-15 10:09:36 -05:00
parent 1768001881
commit 73916ade45
No known key found for this signature in database
GPG Key ID: 38C73B40DFA809EE
3 changed files with 10 additions and 9 deletions

View File

@ -7,11 +7,11 @@
export default ['$filter', '$state', '$stateParams', '$http', 'Wait',
'$scope', '$rootScope', 'CreateSelect2', 'ParseTypeChange', 'GetBasePath',
'Rest', 'ParentObject', 'JobTemplateModel', '$q', 'Empty', 'SchedulePost',
'ProcessErrors', 'SchedulerInit', '$location', 'PromptService', 'RRuleToAPI',
'ProcessErrors', 'SchedulerInit', '$location', 'PromptService', 'RRuleToAPI', 'moment',
function($filter, $state, $stateParams, $http, Wait,
$scope, $rootScope, CreateSelect2, ParseTypeChange, GetBasePath,
Rest, ParentObject, JobTemplate, $q, Empty, SchedulePost,
ProcessErrors, SchedulerInit, $location, PromptService, RRuleToAPI) {
ProcessErrors, SchedulerInit, $location, PromptService, RRuleToAPI, moment) {
var base = $scope.base || $location.path().replace(/^\//, '').split('/')[0],
scheduler,
@ -322,12 +322,12 @@ export default ['$filter', '$state', '$stateParams', '$http', 'Wait',
$http.post('/api/v2/schedules/preview/', {'rrule': req})
.then(({data}) => {
$scope.preview_list = data;
for (let tz in data) {
$scope.preview_list.isEmpty = data[tz].length === 0;
$scope.preview_list[tz] = data[tz].map(function(date) {
return date.replace(/Z/, '');
date = date.replace(/Z/, '');
return moment.parseZone(date).format("MM-DD-YYYY HH:mm:ss");
});
}
});

View File

@ -1,7 +1,7 @@
export default ['$filter', '$state', '$stateParams', 'Wait', '$scope',
export default ['$filter', '$state', '$stateParams', 'Wait', '$scope', 'moment',
'$rootScope', '$http', 'CreateSelect2', 'ParseTypeChange', 'ParentObject', 'ProcessErrors', 'Rest',
'GetBasePath', 'SchedulerInit', 'SchedulePost', 'JobTemplateModel', '$q', 'Empty', 'PromptService', 'RRuleToAPI',
function($filter, $state, $stateParams, Wait, $scope,
function($filter, $state, $stateParams, Wait, $scope, moment,
$rootScope, $http, CreateSelect2, ParseTypeChange, ParentObject, ProcessErrors, Rest,
GetBasePath, SchedulerInit, SchedulePost, JobTemplate, $q, Empty, PromptService, RRuleToAPI) {
@ -95,7 +95,8 @@ function($filter, $state, $stateParams, Wait, $scope,
for (let tz in data) {
$scope.preview_list.isEmpty = data[tz].length === 0;
$scope.preview_list[tz] = data[tz].map(function(date) {
return date.replace(/Z/, '');
date = date.replace(/Z/, '');
return moment.parseZone(date).format("MM-DD-YYYY HH:mm:ss");
});
}
});

View File

@ -630,14 +630,14 @@
SchedulerFormDetail-occurrenceList"
ng-show="dateChoice == 'utc'">
<li ng-repeat="occurrence in preview_list.utc">
{{ occurrence | date:'MM-dd-yyyy HH:mm:ss'}} UTC
{{ occurrence }} UTC
</li>
</ul>
<ul class="occurrence-list mono-space
SchedulerFormDetail-occurrenceList"
ng-show="dateChoice == 'local'">
<li ng-repeat="occurrence in preview_list.local">
{{ occurrence | date:'MM-dd-yyyy HH:mm:ss'}}
{{ occurrence }}
</li>
</ul>