技术控

    今日:152| 主题:49194
收藏本版 (1)
最新软件应用技术尽在掌握

[其他] Google CCTZ binding for Node.JS

[复制链接]
释怀°Believe 发表于 4 天前
68 0

立即注册CoLaBug.com会员,免费获得投稿人的专业资料,享用更多功能,玩转个人品牌!

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
node-cctz  

  Because sometimes Moment.JS is slow
  CCTZ is a C++ library for translating between absolute and civil times using the rules of a time zone.  
  Usage

  1. const cctz = require('cctz');
  2. const lax = cctz.load_time_zone('America/Los_Angeles');
  3. const tp = cctz.convert(new cctz.CivilSecond(2015, 9, 22, 9), lax);
  4. const nyc = cctz.load_time_zone('America/New_York');
  5. console.log(cctz.format('Talk starts at %T %z (%Z)', tp, nyc));
  6. // => Talk starts at 12:00:00 -0400 (EDT)
复制代码
API

  cctz.load_time_zone(name)

  Returns TimeZone object for time zone with    namefrom    /usr/share/zoneinfo.  
  Pro-tip: Cache TimeZone objects.  
  cctz.utc_time_zone()

  Returns    UTCTimeZone object.  
  cctz.local_time_zone()

  Returns    localtimeTimeZone object.  
  cctz.parse(format, input, timezone)

  Parses    inputstring according to    formatstring (assuming    inputin    timezone).  
  Returns TimePoint object.
  cctz.format(format, timepoint, timezone)

  Formats TimePoint    timepointobject according to    formatin    timezone.  
  Returns string.
  cctz.convert(timepoint, timezone)

  Returns CivilSecond object from    timepointin    timezone.  
  cctz.convert(civilsecond, timezone)

  Returns TimePoint object from    civilsecondin    timezone.  
  TimePoint

  Holder for          std::chrono::time_point    .  
  TimePoint(unix)

  Creates TimePoint from Unix timestamp (in milliseconds).
  TimePoint.unix

  Returns Unix timestamp in milliseconds.
  CivilSecond

  Holder for          cctz::civil_second    with getters and setters for properties.  
  CivilSecond(year = 0, month = 0, day = 0, hour = 0, minute = 0, second = 0)

  Creates CivilSecond object.
  CivilSecond.year

  CivilSecond.month

  CivilSecond.day

  CivilSecond.hour

  CivilSecond.minute

  CivilSecond.second

  CivilSecond.yearday (only getter)

  CivilSecond.weekday (only getter)

  TimeZone

  Holder for          cctz::time_zone    .  
  TimeZone(name)

  Same as    load_time_zone.  
  TimeZone.lookup(timepoint)

  Returns          cctz::absolute_lookup    object.  
  TimeZone.lookup(civilsecond)

  Returns          cctz::civil_lookup    object.  
  TimeZone.name

  Name of TimeZone.
  Benchmarks

  1. Parse-Format      (Date) x 590,555 ops/sec ±1.64% (83 runs sampled)
  2. Parse-Format      (cctz) x 505,249 ops/sec ±3.95% (78 runs sampled)
  3. Parse-Format    (moment) x 19,295 ops/sec ±2.12% (81 runs sampled)
  4. Increment hour    (Date) x 15,962 ops/sec ±6.53% (79 runs sampled)
  5. Increment hour    (cctz) x 5,718 ops/sec ±1.66% (85 runs sampled)
  6. Increment hour  (moment) x 600 ops/sec ±1.58% (84 runs sampled)
复制代码
Run    npm iand then    npm run bench.  
  License

  MIT ©    Vsevolod Strukchinsky
友荐云推荐




上一篇:Write You A Scheme version 2.0
下一篇:upper.io - database access
酷辣虫提示酷辣虫禁止发表任何与中华人民共和国法律有抵触的内容!所有内容由用户发布,并不代表酷辣虫的观点,酷辣虫无法对用户发布内容真实性提供任何的保证,请自行验证并承担风险与后果。如您有版权、违规等问题,请通过"联系我们"或"违规举报"告知我们处理。

*滑动验证:
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

我要投稿

推荐阅读

扫码访问 @iTTTTT瑞翔 的微博
回页顶回复上一篇下一篇回列表手机版
手机版/CoLaBug.com ( 粤ICP备05003221号 | 文网文[2010]257号 )|网站地图 酷辣虫

© 2001-2016 Comsenz Inc. Design: Dean. DiscuzFans.

返回顶部 返回列表