當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript timezone類代碼示例

本文整理匯總了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);
  }
};
開發者ID:FourtekIT-incubator,項目名稱:bokeh,代碼行數:21,代碼來源:datetime_tick_formatter.ts

示例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)}`;
  });
開發者ID:FourtekIT-incubator,項目名稱:bokeh,代碼行數:46,代碼來源:templating.ts

示例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),
    };
  }
開發者ID:FourtekIT-incubator,項目名稱:bokeh,代碼行數:22,代碼來源:datetime_tick_formatter.ts

示例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);
 }
開發者ID:FourtekIT-incubator,項目名稱:bokeh,代碼行數:5,代碼來源:cell_formatters.ts

示例5: tz

const _array = t => tz(t, "%Y %m %d %H %M %S").split(/\s+/).map(e => parseInt(e, 10));
開發者ID:FourtekIT-incubator,項目名稱:bokeh,代碼行數:1,代碼來源:datetime_tick_formatter.ts


注:本文中的timezone類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。