@171h/utils
Advanced tools
Comparing version 0.4.2 to 0.4.3
@@ -139,2 +139,3 @@ /** | ||
* 一周的工作分钟数数组 | ||
* Note: 0-0:0 为一周的最早开始时间点,6-23:59 为一周的最晚结束时间点 | ||
*/ | ||
@@ -158,2 +159,9 @@ businessMinutes: WeekMinute[]; | ||
}; | ||
/** | ||
* 一个`工作时间段的开始时间点`对应的`上一个工作时间段的非工作结束时间点`映射 | ||
* @example 工作时间段的开始时间点: 上一个工作时间段的非工作结束时间点 | ||
* @example 1-8:0 -> 0-17:0 | ||
* @example 0-8:0 -> 6-17:0 | ||
*/ | ||
prevEndNonBusinessWeekMinute: Record<WeekMinute, WeekMinute>; | ||
} | ||
@@ -207,2 +215,9 @@ | ||
/** | ||
* 工作时间的基准时间 | ||
* 1. 1970-01-04 00:00:00 是星期日 | ||
* 2. 这个时间点的工作时间是 0 | ||
*/ | ||
declare const basetime: Date; | ||
/** | ||
* 获取一个日期格式的工作时间相对于基准时间(1970-01-04 00:00:00)的分钟数 | ||
@@ -214,3 +229,3 @@ * @param date 日期 eg: 2021-01-01 00:00 2023-05-27 11:11 | ||
*/ | ||
declare function getBusinessTime(date: string | number | Date, options?: { | ||
declare function getBusinessTime(date: Date, options?: { | ||
minuteMaps?: MinuteMaps; | ||
@@ -220,5 +235,20 @@ holidays?: Date[]; | ||
/** | ||
* 获取两个日期之间的节假日日期数组 | ||
* @param start // 开始日期 | ||
* @param end // 结束日期 | ||
* @param holidays // 节假日数组 | ||
* @returns | ||
*/ | ||
declare function daysBetween(start: Date, end: Date, holidays: Date[]): Date[]; | ||
/** | ||
* 获取所有日期的总的工作时间的分钟数 | ||
* @param days // 日期数组 | ||
* @param minuteMaps // 工作时间配置 | ||
* @returns | ||
*/ | ||
declare function sumBusinessMinutes(days: Date[], minuteMaps?: MinuteMaps): number; | ||
/** | ||
* 将相对于基准时间(1970-01-04 00:00:00)的分钟数转换为日期格式的工作时间 | ||
* @param time // 工作时间点 | ||
* @param options minuteMaps: 工作时间配置 holidays: 节假日数组 | ||
* @param options minuteMaps: 工作时间配置 holidays: 节假日数组 enableNonBusinessEndTime: 是否允许非工作时间的结束时间作为返回值,默认不允许 | ||
* @returns | ||
@@ -230,2 +260,3 @@ * Note: holidays 必须从小到大排序(内部不再排序,避免浪费性能) | ||
holidays?: Date[]; | ||
enableNonBusinessEndTime?: boolean; | ||
}): Date; | ||
@@ -240,3 +271,3 @@ /** | ||
*/ | ||
declare function diffBusinessMinutes(start: string | number | Date, end: string | number | Date, options?: { | ||
declare function diffBusinessMinutes(start: Date, end: Date, options?: { | ||
minuteMaps?: MinuteMaps; | ||
@@ -249,9 +280,11 @@ holidays?: Date[]; | ||
* @param amount // 增加(减少)的分钟数 | ||
* @param options minuteMaps: 工作时间配置 holidays: 节假日数组 | ||
* @param options minuteMaps: 工作时间配置 holidays: 节假日数组 disabledNonBusinessEndTime: 是否禁用非工作时间结束,默认不禁用 | ||
* @returns | ||
* Note: holidays 必须从小到大排序(内部不再排序,避免浪费性能) | ||
* Note: 当 amount 为 0 时,disabledNonBusinessEndTime无论是否传递参数都将将保持禁用,直接下一个工作时间点 | ||
*/ | ||
declare function addBusinessMinutes(start: string | number | Date, amount: number, options?: { | ||
declare function addBusinessMinutes(start: number | Date, amount: number, options?: { | ||
minuteMaps?: MinuteMaps; | ||
holidays?: Date[]; | ||
disabledNonBusinessEndTime?: boolean; | ||
}): Date; | ||
@@ -283,2 +316,8 @@ | ||
/** | ||
* 将星期几-时间点转换为一周内的分钟数 | ||
* @param weekMinute | ||
* @returns | ||
*/ | ||
declare function weekMinuteToNum(weekMinute: WeekMinute | '7-0:0'): number; | ||
/** | ||
* 根据匹配字符串获取日期字符串数组 | ||
@@ -338,2 +377,2 @@ * @param match // 2016-*-*, 2016-01-*, *-01-01 .... | ||
export { BusinessHours, BusinessHoursMap, Calendar, CalendarConfig, DD, DateTimeString, DayUnit, DurationUnit, HolidayDetail, Hour, HourUnit, MM, Minute, MinuteMaps, MinuteUnit, MonthUnit, Second, SecondUnit, Time, WeekDay, WeekMinute, WeekUnit, YYYY, YearUnit, addBusinessMinutes, assert, businessHoursMap, businessMinuteMap, businessTimeToDate, calendar24Hours, calendarNight, calendarStd, calendarWeek5, dayUnits, daysNameMaps, daysNames, diffBusinessMinutes, getBusinessTime, getDateFromMatch, getTypeName, holidays, hourUnits, isArray, isArrayOfObject, isBoolean, isBrowser, isDate, isDayUnit, isDef, isFunction, isHourUnit, isMinuteUnit, isMonthUnit, isNull, isNumber, isObject, isRegExp, isSecondUnit, isString, isUndefined, isValid, isWeekUnit, isWindow, isYearUnit, maxDate, minDate, minuteUnits, monthUnits, noop, numToTime, numToWeekMinute, secondUnits, timeToNum, toString, units, weekUnits, yearUnits }; | ||
export { BusinessHours, BusinessHoursMap, Calendar, CalendarConfig, DD, DateTimeString, DayUnit, DurationUnit, HolidayDetail, Hour, HourUnit, MM, Minute, MinuteMaps, MinuteUnit, MonthUnit, Second, SecondUnit, Time, WeekDay, WeekMinute, WeekUnit, YYYY, YearUnit, addBusinessMinutes, assert, basetime, businessHoursMap, businessMinuteMap, businessTimeToDate, calendar24Hours, calendarNight, calendarStd, calendarWeek5, dayUnits, daysBetween, daysNameMaps, daysNames, diffBusinessMinutes, getBusinessTime, getDateFromMatch, getTypeName, holidays, hourUnits, isArray, isArrayOfObject, isBoolean, isBrowser, isDate, isDayUnit, isDef, isFunction, isHourUnit, isMinuteUnit, isMonthUnit, isNull, isNumber, isObject, isRegExp, isSecondUnit, isString, isUndefined, isValid, isWeekUnit, isWindow, isYearUnit, maxDate, minDate, minuteUnits, monthUnits, noop, numToTime, numToWeekMinute, secondUnits, sumBusinessMinutes, timeToNum, toString, units, weekMinuteToNum, weekUnits, yearUnits }; |
{ | ||
"name": "@171h/utils", | ||
"type": "module", | ||
"version": "0.4.2", | ||
"version": "0.4.3", | ||
"packageManager": "pnpm@8.1.1", | ||
@@ -44,3 +44,3 @@ "description": "", | ||
"prepublishOnly": "nr build", | ||
"release": "bumpp && npm publish --access public", | ||
"release": "npx changelogen@latest --release && npm publish --access public", | ||
"start": "esno src/index.ts", | ||
@@ -61,2 +61,3 @@ "test": "vitest --watch", | ||
"bumpp": "^9.1.0", | ||
"changelogen": "^0.5.3", | ||
"dayjs": "^1.11.7", | ||
@@ -63,0 +64,0 @@ "eslint": "^8.41.0", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
35036
431
22