本文整理汇总了TypeScript中timezone类的典型用法代码示例。如果您正苦于以下问题:TypeScript timezone类的具体用法?TypeScript timezone怎么用?TypeScript timezone使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了timezone类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
const _strftime = function(t, format) {
if (isFunction(format)) {
return format(t);
} else {
// Python's datetime library augments the microsecond directive %f, which is not
// supported by the javascript library timezone: http://bigeasy.github.io/timezone/.
// Use a regular expression to replace %f directive with microseconds.
// TODO: what should we do for negative microsecond strings?
const microsecond_replacement_string = sprintf("$1%06d", _us(t));
format = format.replace(/((^|[^%])(%%)*)%f/, microsecond_replacement_string);
if (format.indexOf("%") === -1) {
// timezone seems to ignore any strings without any formatting directives,
// and just return the time argument back instead of the string argument.
// But we want the string argument, in case a user supplies a format string
// which doesn't contain a formatting directive or is only using %f.
return format;
}
return tz(t, format);
}
};
示例2: Error
string = string.replace(/(^|[^@])@(?:(\$?\w+)|{([^{}]+)})(?:{([^{}]+)})?/g, (_match, prefix, name, long_name, format) => {
name = (long_name != null) ? long_name : name;
const value =
name[0] === "$" ?
special_vars[name.substring(1)]
:
__guard__(data_source.get_column(name), x => x[i]);
let replacement = null;
if ((value == null)) {
replacement = "???";
} else {
// 'safe' format, just return the value as is
if (format === 'safe') {
return `${prefix}${value}`;
} else if (format != null) {
// see if the field has an entry in the formatters dict
if ((formatters != null) && name in formatters) {
if (formatters[name] === "numeral") {
replacement = Numbro.format(value, format);
} else if (formatters[name] === "datetime") {
replacement = tz(value, format);
} else if (formatters[name] === "printf") {
replacement = sprintf(format, value);
} else {
throw new Error(`Unknown tooltip field formatter type '${ formatters[name] }'`);
}
// if not assume the format string is Numbro
} else {
replacement = Numbro.format(value, format);
}
// no format supplied, just use a basic default numeric format
} else {
replacement = _format_number(value);
}
}
return replacement = `${prefix}${escape(replacement)}`;
});
示例3: unzip
_update_width_formats() {
const now = tz(new Date());
const _widths = function(fmt_strings) {
const sizes = (fmt_strings.map((fmt_string) => _strftime(now, fmt_string).length));
const sorted = sortBy(zip(sizes, fmt_strings), function(...args) { const [size,] = args[0]; return size; });
return unzip(sorted);
};
return this._width_formats = {
microseconds: _widths(this.microseconds),
milliseconds: _widths(this.milliseconds),
seconds: _widths(this.seconds),
minsec: _widths(this.minsec),
minutes: _widths(this.minutes),
hourmin: _widths(this.hourmin),
hours: _widths(this.hours),
days: _widths(this.days),
months: _widths(this.months),
years: _widths(this.years),
};
}
示例4: doFormat
doFormat(row, cell, value, columnDef, dataContext) {
value = isString(value) ? parseInt(value, 10) : value;
const date = tz(value, this.getFormat());
return super.doFormat(row, cell, date, columnDef, dataContext);
}
示例5: tz
const _array = t => tz(t, "%Y %m %d %H %M %S").split(/\s+/).map(e => parseInt(e, 10));