本文整理汇总了TypeScript中moment-timezone.tz类的典型用法代码示例。如果您正苦于以下问题:TypeScript tz类的具体用法?TypeScript tz怎么用?TypeScript tz使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了tz类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: transform
transform(value: any, timezoneFrom?: string, timezoneTo?: string): string {
if (typeof value === 'string') {
value = parseInt(value, 10);
if (isNaN(value)) {
return '';
}
}
if (typeof value !== 'number' && !(value instanceof Date) && !moment.isMoment(value)) {
return '';
}
if (!timezoneFrom) {
return typeof value === 'number'
? this.hourToString(value)
: moment.utc(value).format('HH:mm');
} else {
timezoneTo = timezoneTo ? timezoneTo : moment.tz.guess();
return moment
.tz(
typeof value === 'number'
? this.hourToString(value)
: moment.utc(value).format('HH:mm'),
'HH:mm',
timezoneFrom
)
.tz(timezoneTo)
.format('HH:mm');
}
}
示例2: afterEach
afterEach(() => {
moment.tz.setDefault('Browser');
});
示例3: beforeEach
beforeEach(() => {
moment.tz.setDefault('UTC');
});
示例4:
import * as Constants from '@js/constants/index'
import * as Cookies from 'js-cookie'
import * as GibsonApi from '@js/api/gibsonApi'
import * as Moment from 'moment-timezone'
// set timezone globally
Moment.tz.setDefault('Asia/Tokyo')
// functions for eventlistener
let eventOffline
let eventOnline
let eventBeforeunloadAlert
let eventBeforeunloadCookie
const state = {
serverTimeOffset: undefined,
isLoading: false,
isOnline: true,
isDev: Constants.isDev,
errorCode: undefined,
constants: Constants
}
const getters = {
isLoading: state => state.isLoading,
isOnline: state => state.isOnline,
isDev: state => state.isDev,
errorCode: state => state.errorCode,
constants: state => state.constants
}
const actions = {