1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

update datetime

This commit is contained in:
Luke Pulverenti 2016-09-16 02:32:40 -04:00
parent 965f9741ba
commit bbb9e89063
12 changed files with 57 additions and 113 deletions

View file

@ -109,59 +109,29 @@
return locale;
}
function toLocaleString(date) {
function toLocaleString(date, options) {
var currentLocale = getCurrentLocale();
return currentLocale && toLocaleTimeStringSupportsLocales ?
date.toLocaleString(currentLocale) :
date.toLocaleString(currentLocale, options || {}) :
date.toLocaleString();
}
function getLocaleDateStringParts(date) {
var day = getDayName(date);
date = toLocaleDateString(date);
var parts = [];
if (date.toLowerCase().indexOf(day.toLowerCase()) == -1) {
parts.push(day);
}
parts.push(date);
return parts;
}
function getDayName(date) {
var weekday = [];
weekday[0] = globalize.translate('sharedcomponents#Sunday');
weekday[1] = globalize.translate('sharedcomponents#Monday');
weekday[2] = globalize.translate('sharedcomponents#Tuesday');
weekday[3] = globalize.translate('sharedcomponents#Wednesday');
weekday[4] = globalize.translate('sharedcomponents#Thursday');
weekday[5] = globalize.translate('sharedcomponents#Friday');
weekday[6] = globalize.translate('sharedcomponents#Saturday');
return weekday[date.getDay()];
}
function toLocaleDateString(date) {
function toLocaleDateString(date, options) {
var currentLocale = getCurrentLocale();
return currentLocale && toLocaleTimeStringSupportsLocales ?
date.toLocaleDateString(currentLocale) :
date.toLocaleDateString(currentLocale, options || {}) :
date.toLocaleDateString();
}
function toLocaleTimeString(date) {
function toLocaleTimeString(date, options) {
var currentLocale = getCurrentLocale();
return currentLocale && toLocaleTimeStringSupportsLocales ?
date.toLocaleTimeString(currentLocale) :
date.toLocaleTimeString(currentLocale, options || {}) :
date.toLocaleTimeString();
}
@ -194,7 +164,13 @@
if (minutes < 10) {
minutes = '0' + minutes;
}
time = hour + ':' + minutes + suffix;
if (minutes == '00') {
minutes = '';
} else {
minutes = ':' + minutes;
}
time = hour + minutes + suffix;
} else {
var timeParts = time.split(':');
@ -224,7 +200,6 @@
toLocaleDateString: toLocaleDateString,
toLocaleString: toLocaleString,
getDisplayTime: getDisplayTime,
isRelativeDay: isRelativeDay,
getLocaleDateStringParts: getLocaleDateStringParts
isRelativeDay: isRelativeDay
};
});