前端开源框架如何提升开发效率与用户体验的关键因素
559
2022-10-12
tinydate 一个微小(337B)可复重日期格式化程序。 非常快!
A tiny (337B) reusable date formatter. Extremely fast!
Demo
Inspired by tinytime, this module returns a "render" function that efficiently re-render your deconstructed template. This allows for incredibly performant results!
However, please notice that this only provides a limited subset of Date methods. If you need more, tinytime or date-fns are great alternatives!
Install
$ npm install --save tinydate
Usage
const tinydate = require('tinydate');const fooDate = new Date('5/1/2017, 4:30:09 PM');const stamp = tinydate('Current time: [{HH}:{mm}:{ss}]');stamp(fooDate);//=> Current time: [16:30:09]stamp();//=> Current time: [17:09:34]
API
tinydate(pattern)(date)
pattern
Type: string
The template pattern to be parsed.
date
Type: Date Default: new Date()
The date from which to retrieve values. Defaults to current datetime.
Patterns
{YYYY}: full year; eg: 2017{YY}: short year; eg: 17{MM}: month; eg: 04{DD}: day; eg: 01{HH}: hours; eg: 06 (24h){mm}: minutes; eg: 59{ss}: seconds; eg: 09
Benchmarks
tinydate --> 72,236,210 ops/sec ±0.89% (91 runs sampled)tinytime --> 27,530,608 ops/sec ±0.92% (93 runs sampled)time-stamp --> 569,692 ops/sec ±0.80% (90 runs sampled)
License
MIT © Luke Edwards
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~