该函数用于获取指定时间的时间刻度。
Yuka.Time.getTimescale(time, timescale)
time:需要获取时间刻度的时间,可以是Date对象或时间戳(毫秒)。timescale:表示时间刻度的字符串,默认值为'second'。可选值包括:'second'、'minute'、'hour'、'day'、'month'和'year'。该函数返回一个具有start和end属性的对象,表示指定时间的时间刻度范围。
// 获取当前时间的月份时间刻度范围
const now = new Date();
const timescale = Yuka.Time.getTimescale(now, 'month');
console.log(timescale.start, timescale.end); // 输出本月的第一天和最后一天的日期
time参数的类型,如果是时间戳,则将其转换为Date对象。timescale参数的值,获取指定时间所在时间刻度范围的开始时间和结束时间。