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 2, 2016
1 parent bd36a7c commit 06ccab6
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 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,
@@ -18,6 +18,21 @@ module.exports = ['PostEndpoint', function (PostEndpoint) {
return PostEndpoint.get({ id : entry });
});
}
if ($scope.attribute.type === 'datetime' && $scope.attribute.input === 'date') {
$scope.value = $scope.value.map(function (entry) {
return moment(entry).format('LL');
});
}
if ($scope.attribute.type === 'datetime' && $scope.attribute.input === 'datetime') {
$scope.value = $scope.value.map(function (entry) {
return moment(entry).format('LLL');
});
}
if ($scope.attribute.type === 'datetime' && $scope.attribute.input === 'time') {
$scope.value = $scope.value.map(function (entry) {
return moment(entry).format('LT');
});
}
}
};
}];

0 comments on commit 06ccab6

Please sign in to comment.