support set timezone

This commit is contained in:
MaysWind
2021-03-07 23:59:13 +08:00
parent 7c47b3253e
commit fc2023fba2
14 changed files with 127 additions and 27 deletions
+3
View File
@@ -8,6 +8,7 @@ const serverSettingsCookieKey = 'lab_server_settings';
const defaultSettings = {
lang: 'en',
timeZone: '',
debug: false,
applicationLock: false,
applicationLockWebAuthn: false,
@@ -128,6 +129,8 @@ export default {
isProduction: () => process.env.NODE_ENV === 'production',
getLanguage: () => getOriginalOption('lang'),
setLanguage: value => setOption('lang', value),
getTimezone: () => getOption('timeZone'),
setTimezone: value => setOption('timeZone', value),
isEnableDebug: () => getOption('debug'),
setEnableDebug: value => setOption('debug', value),
isEnableApplicationLock: () => getOption('applicationLock'),
+15 -6
View File
@@ -34,12 +34,20 @@ function isBoolean(val) {
return typeof(val) === 'boolean';
}
function parseDateFromUnixTime(unixTime) {
return moment.unix(unixTime);
function getTimezoneOffset(timezone) {
if (timezone) {
return moment().tz(timezone).format('Z');
} else {
return moment().format('Z');
}
}
function formatDate(date, format) {
return moment(date).format(format);
function getCurrentUnixTime() {
return moment().unix();
}
function parseDateFromUnixTime(unixTime) {
return moment.unix(unixTime);
}
function formatUnixTime(unixTime, format) {
@@ -107,7 +115,7 @@ function getMinuteLastUnixTime(date) {
}
function getTodayFirstUnixTime() {
return moment({ hour: 0, minute: 0, second: 0, millisecond: 0 }).unix();
return moment().set({ hour: 0, minute: 0, second: 0, millisecond: 0 }).unix();
}
function getTodayLastUnixTime() {
@@ -562,8 +570,9 @@ export default {
isString,
isNumber,
isBoolean,
getTimezoneOffset,
getCurrentUnixTime,
parseDateFromUnixTime,
formatDate,
formatUnixTime,
getUnixTime,
getYear,