
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
@calenderjs/date-time
Advanced tools
CalenderJS 日期时间工具函数库 - 提供统一的日期和时间处理工具
Date 对象和日期字符串(ISO 8601 格式)pnpm add @calenderjs/date-time
import {
getMonthStart,
getMonthEnd,
getWeekDates,
isSameDay,
formatDateKey,
getTimeString,
} from "@calenderjs/date-time";
// 支持 Date 对象
const date = new Date(2024, 0, 15);
const monthStart = getMonthStart(date);
// 支持字符串日期
const monthStart2 = getMonthStart("2024-01-15");
// 判断同一天
const isSame = isSameDay("2024-01-15", new Date(2024, 0, 15));
// 格式化日期
const dateKey = formatDateKey(new Date(2024, 0, 15)); // "2024-01-15"
const timeStr = getTimeString(new Date(2024, 0, 15, 14, 30, 0)); // "14:30"
getMonthStart(date: Date | string): Date - 获取月份的第一天getMonthEnd(date: Date | string): Date - 获取月份的最后一天getWeekStart(date: Date | string, firstDayOfWeek?: 0 | 1): Date - 获取周的开始日期(周一)getWeekEnd(date: Date | string, firstDayOfWeek?: 0 | 1): Date - 获取周的结束日期(周日)getWeekDates(date: Date | string, firstDayOfWeek?: 0 | 1): Date[] - 获取日期所在周的所有日期getMonthDates(date: Date | string, firstDayOfWeek?: 0 | 1): Date[] - 获取月份的所有日期(包括前后月份)isSameDay(date1: Date | string, date2: Date | string): boolean - 判断两个日期是否是同一天isToday(date: Date | string): boolean - 判断是否是今天isSameMonth(date1: Date | string, date2: Date | string): boolean - 判断日期是否在同一个月isBusinessDay(date: Date | string): boolean - 判断是否是工作日(周一到周五)isWeekend(date: Date | string): boolean - 判断是否是周末(周六或周日)daysBetween(date1: Date | string, date2: Date | string): number - 计算两个日期之间的天数generateDateGrid(date: Date | string, firstDayOfWeek?: 0 | 1): Date[] - 生成日期网格(用于月视图)isValidTimeRange(startTime: Date | string, endTime: Date | string): boolean - 验证时间范围是否有效calculateDuration(startTime: Date | string, endTime: Date | string): number - 计算持续时间(分钟数)isTimeInRange(time: Date | string, startTime: Date | string, endTime: Date | string): boolean - 判断时间是否在范围内isBusinessHours(date: Date | string, startHour?: number, endHour?: number, useUTC?: boolean): boolean - 判断是否在工作时间getDayHours(): number[] - 获取一天的所有小时(0-23)generateTimeSlots(minTime?: string, maxTime?: string, slotDuration?: number): Array<{ hour: number; minute: number }> - 生成时间槽列表formatDateKey(date: Date | string): string - 格式化日期为 YYYY-MM-DDgetTimeString(date: Date | string): string - 获取日期的小时和分钟(HH:mm 格式)formatTime(date: Date | string, format?: "12h" | "24h"): string - 格式化时间(支持 12/24 小时制)# 运行测试
pnpm test
# 运行测试并生成覆盖率报告
pnpm test -- --coverage
pnpm build
MIT
FAQs
CalenderJS 日期时间工具函数库 - 提供统一的日期和时间处理工具
We found that @calenderjs/date-time demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.