Lidarr/UI/Handlebars/Helpers/DateTime.js

47 lines
1.2 KiB
JavaScript
Raw Normal View History

2013-06-22 06:24:24 +00:00
'use strict';
define(
[
2013-06-25 04:43:16 +00:00
'handlebars',
'sugar'
2013-06-25 04:43:16 +00:00
], function (Handlebars) {
Handlebars.registerHelper('ShortDate', function (input) {
if (!input) {
return '';
}
2013-06-25 04:43:16 +00:00
var date = Date.create(input);
var result = '<span title="' + date.full() + '">' + date.short() + '</span>';
2013-06-25 04:43:16 +00:00
return new Handlebars.SafeString(result);
});
2013-07-17 00:41:04 +00:00
Handlebars.registerHelper('Day', function (input) {
if (!input) {
return '';
}
return Date.create(input).format('{dd}');
});
Handlebars.registerHelper('Month', function (input) {
if (!input) {
return '';
}
return Date.create(input).format('{Mon}');
});
Handlebars.registerHelper('StartTime', function (input) {
if (!input) {
return '';
}
var date = Date.create(input);
if (date.format('{mm}') === '00') {
return date.format('{h}{tt}');
}
return date.format('{h}.{mm}{tt}');
});
});