@ 日期/ 生成器
以可读函数链生成日期 .
此外,还有接受数字的功能,以帮助使用其他地方提供的值.
安装
npm install @date/generator --save
使用量
var gen = require('@date/generator')
// these are equivalent:
// specify each thing individually
var washingtonDay = gen.third().monday().in().february().of(2016)
// skip the in() and of() and specify the year in the february() call
var washingtonDay = gen.third().monday().february(2016)
// specify 'third' with a '3' to monday(),
// 'february' with '1' to month()
var washingtonDay = gen.monday(3).month(1).of(2016)
var thanksgiving = gen.fourth().thursday().in().november().of(2016)
顺序
从顺序函数开始 :
first()- 1个second()- 2个third()- 3个fourth()- 4个last()- 5(将是最后一个,即使最后一个是第四个)
天数
在调用命令函数后, 或从它们开始, 指定命令值为 1-5 之后, 日函数可以使用 :
sunday()monday()tuesday()wednesday()thursday()friday()saturday()
月份数
调用一日函数后可调用月份函数 :
january()february()march()april()may()june()july()august()september()october()november()december()
还有捷径呼叫 of(year) 后面写明月份的年份 august(2016)。 。 。 .
年份
最后调用指定运行的年份 of(year) 返回日期实例.