IsBetween
IsBetween 增加了 .isBetween()
API 返回一个 boolean
来展示一个时间是否介于两个时间之间.
var isBetween = require("dayjs/plugin/isBetween");
// import isBetween from 'dayjs/plugin/isBetween' // ES 2015
dayjs.extend(isBetween);
// To use `year` granularity pass the third parameter
dayjs("2010-10-20").isBetween("2010-10-19", dayjs("2010-10-25"), "year");
// Parameter 4 is a string with two characters; '[' means inclusive, '(' exclusive
// '()' excludes start and end date (default)
// '[]' includes start and end date
// '[)' includes the start date but excludes the stop
// Granuality offers the precision on start and end inclusive checks.
// 例如,当想包含开始的日期作为比较依据,你应该使用“day”作为第三个参数。
dayjs("2016-10-30").isBetween("2016-01-01", "2016-10-30", "day", "[)");