mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-27 22:56:45 -04:00
Calendar/Date localization
New: Choose calendar starting day of week New: Choose prefered date/time formats New: Option to disable relative dates and show absolute dates instead
This commit is contained in:
@@ -3,8 +3,9 @@
|
||||
define(
|
||||
[
|
||||
'moment',
|
||||
'filesize'
|
||||
], function (Moment, Filesize) {
|
||||
'filesize',
|
||||
'Shared/UiSettingsModel'
|
||||
], function (moment, filesize, UiSettings) {
|
||||
|
||||
return {
|
||||
|
||||
@@ -15,16 +16,15 @@ define(
|
||||
return '';
|
||||
}
|
||||
|
||||
return Filesize(size, { base: 2, round: 1 });
|
||||
return filesize(size, { base: 2, round: 1 });
|
||||
},
|
||||
|
||||
dateHelper: function (sourceDate) {
|
||||
relativeDate: function (sourceDate) {
|
||||
if (!sourceDate) {
|
||||
return '';
|
||||
}
|
||||
|
||||
var date = Moment(sourceDate);
|
||||
|
||||
var date = moment(sourceDate);
|
||||
var calendarDate = date.calendar();
|
||||
|
||||
//TODO: It would be nice to not have to hack this...
|
||||
@@ -34,12 +34,12 @@ define(
|
||||
return strippedCalendarDate;
|
||||
}
|
||||
|
||||
if (date.isAfter(Moment())) {
|
||||
if (date.isAfter(moment())) {
|
||||
return date.fromNow(true);
|
||||
}
|
||||
|
||||
if (date.isBefore(Moment().add('years', -1))) {
|
||||
return date.format('ll');
|
||||
if (date.isBefore(moment().add('years', -1))) {
|
||||
return date.format(UiSettings.get('shortDateFormat'));
|
||||
}
|
||||
|
||||
return date.fromNow();
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'backbone',
|
||||
'api!config/ui'
|
||||
], function (Backbone, uiSettings) {
|
||||
var UiSettings = Backbone.Model.extend({
|
||||
|
||||
url : window.NzbDrone.ApiRoot + '/config/ui',
|
||||
|
||||
shortDateTime : function () {
|
||||
return this.get('shortDateFormat') + ' ' + this.get('timeFormat').replace('(', '').replace(')', '');
|
||||
},
|
||||
|
||||
longDateTime : function () {
|
||||
return this.get('longDateFormat') + ' ' + this.get('timeFormat').replace('(', '').replace(')', '');
|
||||
}
|
||||
});
|
||||
|
||||
var instance = new UiSettings(uiSettings);
|
||||
return instance;
|
||||
});
|
||||
Reference in New Issue
Block a user