• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript timezone类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript tiny-lr类代码示例发布时间:2022-05-28
下一篇:
TypeScript tildify类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap