diff --git a/src/NzbDrone.Core/History/HistoryService.cs b/src/NzbDrone.Core/History/HistoryService.cs
index ba2e64705..5ef06aa1a 100644
--- a/src/NzbDrone.Core/History/HistoryService.cs
+++ b/src/NzbDrone.Core/History/HistoryService.cs
@@ -98,6 +98,7 @@ namespace NzbDrone.Core.History
history.Data.Add("ReleaseGroup", message.Episode.ParsedEpisodeInfo.ReleaseGroup);
history.Data.Add("Age", message.Episode.Release.Age.ToString());
history.Data.Add("AgeHours", message.Episode.Release.AgeHours.ToString());
+ history.Data.Add("AgeMinutes", message.Episode.Release.AgeMinutes.ToString());
history.Data.Add("PublishedDate", message.Episode.Release.PublishDate.ToString("s") + "Z");
history.Data.Add("DownloadClient", message.DownloadClient);
diff --git a/src/UI/Activity/History/Details/HistoryDetailsAge.js b/src/UI/Activity/History/Details/HistoryDetailsAge.js
index 79e30c51e..a7c40f69a 100644
--- a/src/UI/Activity/History/Details/HistoryDetailsAge.js
+++ b/src/UI/Activity/History/Details/HistoryDetailsAge.js
@@ -1,13 +1,21 @@
var Handlebars = require('handlebars');
+var FormatHelpers = require('../../../Shared/FormatHelpers');
Handlebars.registerHelper('historyAge', function() {
- var unit = 'days';
var age = this.age;
+ var unit = FormatHelpers.plural(Math.round(age), 'day');
+ var ageHours = parseFloat(this.ageHours);
+ var ageMinutes = this.ageMinutes ? parseFloat(this.ageMinutes) : null;
if (age < 2) {
- unit = 'hours';
- age = parseFloat(this.ageHours).toFixed(1);
+ age = ageHours.toFixed(1);
+ unit = FormatHelpers.plural(Math.round(ageHours), 'hour');
+ }
+
+ if (age < 2 && ageMinutes) {
+ age = parseFloat(ageMinutes).toFixed(1);
+ unit = FormatHelpers.plural(Math.round(ageMinutes), 'minute');
}
return new Handlebars.SafeString('
Age (when grabbed):{0} {1}'.format(age, unit));
diff --git a/src/UI/Release/AgeCell.js b/src/UI/Release/AgeCell.js
index 4d6880425..f5a4bc7de 100644
--- a/src/UI/Release/AgeCell.js
+++ b/src/UI/Release/AgeCell.js
@@ -1,7 +1,7 @@
var moment = require('moment');
var Backgrid = require('backgrid');
var UiSettings = require('../Shared/UiSettingsModel');
-require('../Shared/FormatHelpers');
+var FormatHelpers = require('../Shared/FormatHelpers');
module.exports = Backgrid.Cell.extend({
className : 'age-cell',
@@ -9,27 +9,25 @@ module.exports = Backgrid.Cell.extend({
render : function() {
var age = this.model.get('age');
var ageHours = this.model.get('ageHours');
+ var ageMinutes = this.model.get('ageMinutes');
var published = moment(this.model.get('publishDate'));
var publishedFormatted = published.format('{0} {1}'.format(UiSettings.get('shortDateFormat'), UiSettings.time(true, true)));
var formatted = age;
- var suffix = this.plural(age, 'day');
+ var suffix = FormatHelpers.plural(age, 'day');
- if (age === 0) {
+ if (age < 2) {
formatted = ageHours.toFixed(1);
- suffix = this.plural(Math.round(ageHours), 'hour');
+ suffix = FormatHelpers.plural(Math.round(ageHours), 'hour');
+ }
+
+ if (ageHours < 2) {
+ formatted = ageMinutes.toFixed(1);
+ suffix = FormatHelpers.plural(Math.round(ageMinutes), 'minute');
}
this.$el.html('{0} {1}
'.format(formatted, suffix, publishedFormatted));
this.delegateEvents();
return this;
- },
-
- plural : function(input, unit) {
- if (input === 1) {
- return unit;
- }
-
- return unit + 's';
}
});
\ No newline at end of file
diff --git a/src/UI/Shared/FormatHelpers.js b/src/UI/Shared/FormatHelpers.js
index 4de9bcb10..8abe4207c 100644
--- a/src/UI/Shared/FormatHelpers.js
+++ b/src/UI/Shared/FormatHelpers.js
@@ -54,5 +54,13 @@ module.exports = {
}
return input.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
+ },
+
+ plural : function(input, unit) {
+ if (input === 1) {
+ return unit;
+ }
+
+ return unit + 's';
}
};
\ No newline at end of file