1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2025-07-15 01:25:05 +02:00
Files
Sonarr/UI/Handlebars/Helpers/DateTime.js

59 lines
1.5 KiB
JavaScript
Raw Normal View History

2013-06-21 23:24:24 -07:00
'use strict';
define(
[
2013-06-24 21:43:16 -07:00
'handlebars',
'moment',
'Shared/FormatHelpers'
], function (Handlebars, Moment, FormatHelpers) {
2013-06-24 21:43:16 -07:00
Handlebars.registerHelper('ShortDate', function (input) {
if (!input) {
return '';
}
var date = Moment(input);
var result = '<span title="' + date.format('LLLL') + '">' + date.format('LL') + '</span>';
return new Handlebars.SafeString(result);
});
Handlebars.registerHelper('NextAiring', function (input) {
if (!input) {
return '';
}
var date = Moment(input);
2013-08-03 18:27:12 -07:00
var result = '<span title="' + date.format('LLLL') + '">' + FormatHelpers.dateHelper(input) + '</span>';
2013-06-24 21:43:16 -07:00
return new Handlebars.SafeString(result);
});
2013-07-16 17:41:04 -07:00
Handlebars.registerHelper('Day', function (input) {
if (!input) {
return '';
}
return Moment(input).format('DD');
2013-07-16 17:41:04 -07:00
});
Handlebars.registerHelper('Month', function (input) {
if (!input) {
return '';
}
return Moment(input).format('MMM');
2013-07-16 17:41:04 -07:00
});
Handlebars.registerHelper('StartTime', function (input) {
if (!input) {
return '';
}
var date = Moment(input);
if (date.format('mm') === '00') {
return date.format('ha');
2013-07-16 17:41:04 -07:00
}
return date.format('h.mma');
2013-07-16 17:41:04 -07:00
});
});