Currently, I am encountering an issue with the angular-moment library where it interprets anything exceeding 25 days as a month when using amTimeAgo
.
In the following demonstration, I utilize moment JS to calculate the time difference of 25, 26, and 27 days back from the current date. Subsequently, I employ the amTimeAgo
function to determine the duration from the present moment.
angular.module('timeApp', ['angularMoment'])
.controller('mainController', [ '$scope', function($scope) {
$scope.today = new Date();
$scope.parsedToday = moment($scope.today).format('MM/DD/YYYY hh:mm A');
$scope.days25FromNow = moment($scope.today).subtract({days: 25}).format('MM/DD/YYYY hh:mm A');
$scope.days26FromNow = moment($scope.today).subtract({days: 26}).format('MM/DD/YYYY hh:mm A');
$scope.days27FromNow = moment($scope.today).subtract({days: 27}).format('MM/DD/YYYY hh:mm A');
}]);
<!DOCTYPE html>
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.0/angular.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.16.0/moment.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/angular-moment/1.0.0/angular-moment.min.js"></script>
<link rel="stylesheet" href="style.css" />
<script src="script.js"></script>
</head>
<body>
<div class="container" ng-app="timeApp" ng-controller="mainController as main">
<div>
<h2>AmTimeAgo Issue Beyond 25 Days</h2>
<h3>Current Time: {{ parsedToday}}</h3>
<p>25 Days Ago - {{days25FromNow}} <br>
Original AM Time Ago - {{days25FromNow | amTimeAgo}} <br>
Expected Output - 25 days ago
</p>
<p>26 Days Ago - {{days26FromNow}} <br>
Original AM Time Ago - {{days26FromNow | amTimeAgo}}<br>
Expected Output - 26 days ago
</p>
<p>27 Days Ago - {{days27FromNow}} <br>
Original AM Time Ago - {{days27FromNow | amTimeAgo}}<br>
Expected Output - 27 days ago
</p>
</div>
</div>
</body>
</html>
Identical Example on Plnkr - http://plnkr.co/edit/DZqqI5BC2XNrITThLCS7?p=preview
Is there a specific configuration that can be adjusted to make the calculation consider 30 days as a month? Or could this possibly be a bug? I have reviewed their documentation and source code, yet I am unable to locate where this threshold of 25 days can be modified to 30.
Thank you!