
Security News
AGENTS.md Gains Traction as an Open Format for AI Coding Agents
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
@gez/date-time-kit
Advanced tools
A JavaScript library for handling date and time operations efficiently.
date-time-kit是一个功能强大且易于使用的 TypeScript 库,旨在解决 [web前端 时间区间选择] 的问题。它适用于 [所有web环境],并提供高效、轻量级的解决方案。
使用 npm 安装:
npm install @gez/date-time-kit
使用 yarn 安装:
yarn add @gez/date-time-kit
import { open } from 'date-time-kit';
const result = awiat open({
root: document.getElementById('root')
});
console.log(result);
open(option):kitResult
打开日历选择窗口
option
(kitOption): 初始化对象
export interface kitOption {
root: HTMLElement,
// default select
startTime?: timeString,
endTime?: timeString,
// default limit
maxTime?: timeString,
minTime?: timeString,
// default lang
lang?: lang, // zhCN, enUS ...
// default time zone
timeZone?: number // -12 - 12
}
export type timeString = `${number}-${number}-${number}T${number}:${number}:${number}:${number}`;
export interface kitResult {
startTime: timeString,
endTime: timeString,
// time stamp
startTimeStamp: number,
endTimeStamp: number,
quick: kitDataLimit | null,
timeZone: number
}
示例:
import dataTimeKit from '@gez/date-time-kit';
const result = awiat dataTimeKit.open({
root: document.getElementById('root')
});
console.log(result);
getLimitKeyByTimestamp(startTimestamp: timeString, endTimestamp: timeString, timeZone: number | undefined): kitDataLimit | null
通过时间段获取返回快速选择的时间
getTimestampByLimitKey(limitKey: kitDataLimit, timeZone: number | undefined): kitTimestampResult
通过快速选择的字段获取时间段
getCurrentTimeZone():number
获取当前时区
getDateByTimeZone(date: Date, targetTimeZone: number | undefined, currentTimeZone?: number | undefined): Date
将一个时区的时间转为另一个时区的时间 第三个参数不传默认当前时区
export type kitDataLimit = 'all' | 'today' | 'yesterday' | 'week' | 'lastWeek' | 'last7Days' | 'month' | 'last30Days' | 'last180Days' | 'last6Month' | 'year';
export interface kitTimestampResult {
startTime: timeString,
endTime: timeString,
startTimeStamp: number,
endTimeStamp: number
}
const result = await dataTimeKit.open({
root: document.getElementById('root'),
maxTime: "1990-01-01T00:00:00.000",
minTime: "2050-01-01T00:00:00.000",
startTime: "1990-01-01T00:00:00.000",
endTime: "2050-01-01T00:10:10.022",
enableZone: false,
granularity: dataTimeKit.Granularity.second,
timeZone: 4
});
console.log(result);
欢迎贡献代码!请阅读 贡献指南 以了解如何提交 PR 或报告问题。
本项目基于 MIT 许可证 进行发布。
如果你有任何问题或建议,请随时在 GitHub Issues 提交反馈,或通过 wesloong@gmail.com 联系我们。
⭐️ 如果你觉得这个项目有用,欢迎给个 Star 支持我们!
FAQs
A JavaScript library for handling date and time operations efficiently.
We found that @gez/date-time-kit demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.