lite-ts-time
TypeScript icon, indicating that this package has built-in type declarations

11.2.1 • Public • Published

Version

代码

TimeBase - Time

const dt = new DateTime();
const now = moment();
const res = dt.isSameUnix(
    now.unix(),
    now.endOf('day').unix(),
);
// res = true

const res = dt.startOf(
    now.unix(),
    TimeGranularity.day,
);
// res = 天开始时间(Date)

const res = dt.startOfUnix(
    now.unix(),
    TimeGranularity.day,
);
// res = 天开始时间(时间戳)
  • DateTime - 日期时间
const dateTime = new DateTime();

NowTimeBase - 当前时间

const nowTime: NowTimeBase;

// 判断时间戳与当前时间是否是相同时间粒度
const isSameUnix = await nowTime.isSameUnix(时间戳, 时间粒度);
// isSameUnix = true | false

// 获取当前时间(单位秒)
const unix = await nowTime.unix();
// unix = 1686280002

// 获取当前时间(单位毫秒)
const unixMillisecond = await nowTime.unix(1_000);
// nano = 1686280002000000

// 获取当前时间(单位纳秒)
const unixNano = await nowTime.unix(1_000_000_000);
// nano = 1686280002000000000
  • NowDateTime - Date当前时间
const nowDateTime = new NowDateTime();

Readme

Keywords

Package Sidebar

Install

npm i lite-ts-time

Weekly Downloads

3

Version

11.2.1

License

GPL-3.0

Unpacked Size

45.2 kB

Total Files

15

Last publish

Collaborators

  • ahl5esoft