Skip to content

Commit

Permalink
Format value for post datetime fields nicely
Browse files Browse the repository at this point in the history
  • Loading branch information
rjmackay committed Nov 9, 2016
1 parent bd36a7c commit b79f427
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion app/main/posts/detail/post-value.directive.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = ['PostEndpoint', function (PostEndpoint) {
module.exports = ['PostEndpoint', 'moment', function (PostEndpoint, moment) {
return {
restrict: 'E',
replace: true,
Expand All @@ -18,6 +18,23 @@ module.exports = ['PostEndpoint', function (PostEndpoint) {
return PostEndpoint.get({ id : entry });
});
}
if ($scope.attribute.type === 'datetime') {
if ($scope.attribute.input === 'date') {
$scope.value = $scope.value.map(function (entry) {
return moment(entry).format('LL');
});
}
if ($scope.attribute.input === 'datetime') {
$scope.value = $scope.value.map(function (entry) {
return moment(entry).format('LLL');
});
}
if ($scope.attribute.input === 'time') {
$scope.value = $scope.value.map(function (entry) {
return moment(entry).format('LT');
});
}
}
}
};
}];

0 comments on commit b79f427

Please sign in to comment.