2.0.2 • Published 5 years ago

@wjnpm/time v2.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
5 years ago

Time

用于JavaScript中计算时间范围。传入时间戳,就可以计算时间戳所处当天、当周(周一为第一天)、当月、当年的时间范围。

安装

npm i -S @wjnpm/time
yarn add @wjnpm/time

使用方法

引入包

import { day, week, month, year } from '@wjnpm/time'

传入13位时间戳,获取时间范围

const dayFrame = day(1565158941000); // { startTime: xxxxxxxxxxxxx, endTime: xxxxxxxxxxxxx }
const weekFrame = week(1565158941000); // { startTime: xxxxxxxxxxxxx, endTime: xxxxxxxxxxxxx }
const monthFrame = month(1565158941000); // { startTime: xxxxxxxxxxxxx, endTime: xxxxxxxxxxxxx }
const yearFrame = year(1565158941000); // { startTime: xxxxxxxxxxxxx, endTime: xxxxxxxxxxxxx }

开源协议

遵循 MIT 开源协议.