@dereekb/date 10.1.2 → 10.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.cjs.js +803 -620
- package/index.esm.js +929 -748
- package/package.json +1 -1
- package/src/lib/date/date.cell.d.ts +2 -2
- package/src/lib/date/date.d.ts +11 -0
- package/src/lib/date/date.format.d.ts +21 -3
- package/src/lib/date/date.timezone.d.ts +12 -1
package/package.json
CHANGED
|
@@ -125,7 +125,7 @@ export type DateCellDurationSpan<B extends DateCell = DateCell> = DateDurationSp
|
|
|
125
125
|
/**
|
|
126
126
|
* The DateRange input for dateCellTiming()
|
|
127
127
|
*/
|
|
128
|
-
export type DateCellTimingRangeInput =
|
|
128
|
+
export type DateCellTimingRangeInput = DateRangeDayDistanceInput | DateRange | number;
|
|
129
129
|
/**
|
|
130
130
|
* Can use any timezone instance that has a timezone configured, or is using the
|
|
131
131
|
*/
|
|
@@ -187,7 +187,7 @@ export declare function isValidDateCellTimingStartDate(date: Date): boolean;
|
|
|
187
187
|
*
|
|
188
188
|
* The start date from the inputDate is considered to to have the offset noted in DateCell, and will be retained.
|
|
189
189
|
*/
|
|
190
|
-
export declare function dateCellTiming(durationInput: DateDurationSpan,
|
|
190
|
+
export declare function dateCellTiming(durationInput: DateDurationSpan, rangeInput: DateCellTimingRangeInput, timezoneInput?: DateCellTimingTimezoneInput): FullDateCellTiming;
|
|
191
191
|
export interface DateCellTimingStartPair {
|
|
192
192
|
readonly start: Date;
|
|
193
193
|
readonly normalInstance: DateTimezoneUtcNormalInstance;
|
package/src/lib/date/date.d.ts
CHANGED
|
@@ -117,6 +117,10 @@ export declare function copyHoursAndMinutesFromNow(target: Date, roundDownToMinu
|
|
|
117
117
|
* Creates a new date and copies the hours/minutes from the input date to the target date.
|
|
118
118
|
*/
|
|
119
119
|
export declare function copyHoursAndMinutesFromDate(target: Date, fromDate: Date, roundDownToMinute?: boolean): Date;
|
|
120
|
+
/**
|
|
121
|
+
* Creates a new date using UTC and copies the hours/minutes from the input date using the UTC values to the target date.
|
|
122
|
+
*/
|
|
123
|
+
export declare function copyHoursAndMinutesFromUTCDate(target: Date, fromDate: Date, roundDownToMinute?: boolean): Date;
|
|
120
124
|
/**
|
|
121
125
|
* Creates a new date and copies the hours/minutes from the input onto the target date, if provided. Defaults to now/today otherwise.
|
|
122
126
|
*
|
|
@@ -164,3 +168,10 @@ export declare function readDaysOfWeekNames<T>(values: T[], readDate: ReadDateFu
|
|
|
164
168
|
* @returns
|
|
165
169
|
*/
|
|
166
170
|
export declare function isStartOfDayInUTC(date: Date): boolean;
|
|
171
|
+
/**
|
|
172
|
+
* Returns true if the input date is at midnight for the system.
|
|
173
|
+
*
|
|
174
|
+
* @param date
|
|
175
|
+
* @returns
|
|
176
|
+
*/
|
|
177
|
+
export declare function isStartOfDayForSystem(date: Date): boolean;
|
|
@@ -115,13 +115,23 @@ export declare function formatToDayRangeString(start: Date, end?: Maybe<Date>, f
|
|
|
115
115
|
export declare function safeFormatToISO8601DateString(input: Maybe<DateOrDateString | UTCDateString>): ISO8601DateString | undefined;
|
|
116
116
|
export declare function formatToISO8601DateString(date?: Date): ISO8601DayString;
|
|
117
117
|
/**
|
|
118
|
-
* Converts the input Date or ISO8601DayString to an ISO8601DayString.
|
|
118
|
+
* Converts the input Date or ISO8601DayString to an ISO8601DayString using the system's date (not UTC date).
|
|
119
|
+
*
|
|
120
|
+
* Use formatToISO8601DayStringForUTC() for using the UTC date.
|
|
121
|
+
*
|
|
122
|
+
* @param dateOrString
|
|
123
|
+
* @returns
|
|
124
|
+
*/
|
|
125
|
+
export declare function toISO8601DayStringForSystem(dateOrString: DateOrDayString): ISO8601DayString;
|
|
126
|
+
export declare function formatToISO8601DayStringForSystem(date?: Date): ISO8601DayString;
|
|
127
|
+
/**
|
|
128
|
+
* Converts the input Date or ISO8601DayString to an ISO8601DayString using the UTC date.
|
|
119
129
|
*
|
|
120
130
|
* @param dateOrString
|
|
121
131
|
* @returns
|
|
122
132
|
*/
|
|
123
|
-
export declare function
|
|
124
|
-
export declare function
|
|
133
|
+
export declare function toISO8601DayStringForUTC(dateOrString: DateOrDayString): ISO8601DayString;
|
|
134
|
+
export declare function formatToISO8601DayStringForUTC(date?: Date): ISO8601DayString;
|
|
125
135
|
export declare const dateShortDateStringFormat = "MM/dd/yyyy";
|
|
126
136
|
export declare function formatToShortDateString(date?: Date): ISO8601DayString;
|
|
127
137
|
export declare const dateMonthDayStringFormat = "MM/dd";
|
|
@@ -141,3 +151,11 @@ export declare function formatStartedEndedDistanceString({ start, end }: DateRan
|
|
|
141
151
|
*/
|
|
142
152
|
export declare function toJsDayDate(input: DateOrDayString): Date;
|
|
143
153
|
export declare function parseISO8601DayStringToDate(dayString: ISO8601DayString | ISO8601DateString): Date;
|
|
154
|
+
/**
|
|
155
|
+
* @deprecated use toISO8601DayStringForSystem instead for clarity. Will be removed in the future.
|
|
156
|
+
*/
|
|
157
|
+
export declare const toISO8601DayString: typeof toISO8601DayStringForSystem;
|
|
158
|
+
/**
|
|
159
|
+
* @deprecated use formatToISO8601DayStringForSystem instead for clarity. Will be removed in the future.
|
|
160
|
+
*/
|
|
161
|
+
export declare const formatToISO8601DayString: typeof formatToISO8601DayStringForSystem;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type MapFunction, type Maybe, type Milliseconds, type TimezoneString, type ISO8601DayString, type YearNumber, type MapSameFunction } from '@dereekb/util';
|
|
1
|
+
import { type MapFunction, type Maybe, type Milliseconds, type TimezoneString, type ISO8601DayString, type YearNumber, type MapSameFunction, type Hours } from '@dereekb/util';
|
|
2
2
|
import { type DateRange, type TransformDateRangeDatesFunction } from './date.range';
|
|
3
3
|
/**
|
|
4
4
|
* Inherited from the RRule library where RRule only deals with UTC date/times, dates going into it must always be in UTC.
|
|
@@ -87,6 +87,16 @@ export declare function getCurrentSystemOffsetInHours(date: Date): number;
|
|
|
87
87
|
* @returns
|
|
88
88
|
*/
|
|
89
89
|
export declare function getCurrentSystemOffsetInMinutes(date: Date): number;
|
|
90
|
+
/**
|
|
91
|
+
* Returns the timezone offset in milliseconds.
|
|
92
|
+
*
|
|
93
|
+
* I.E. GMT-5 = -5 hours (in milliseconds)
|
|
94
|
+
*
|
|
95
|
+
* @param timezone
|
|
96
|
+
* @param date
|
|
97
|
+
* @returns
|
|
98
|
+
*/
|
|
99
|
+
export declare function calculateTimezoneOffset(timezone: TimezoneString, date: Date): number;
|
|
90
100
|
export type DateTimezoneConversionTarget = 'target' | 'base' | 'system';
|
|
91
101
|
export type DateTimezoneOffsetFunction = (date: Date, from: DateTimezoneConversionTarget, to: DateTimezoneConversionTarget) => Milliseconds;
|
|
92
102
|
export interface DateTimezoneBaseDateConverter {
|
|
@@ -158,6 +168,7 @@ export declare class DateTimezoneUtcNormalInstance implements DateTimezoneBaseDa
|
|
|
158
168
|
targetDateToSystemDate(date: Date): Date;
|
|
159
169
|
systemDateToTargetDate(date: Date): Date;
|
|
160
170
|
getOffset(date: Date, transform: DateTimezoneUtcNormalInstanceTransformType): Milliseconds;
|
|
171
|
+
getOffsetInHours(date: Date, transform: DateTimezoneUtcNormalInstanceTransformType): Hours;
|
|
161
172
|
offsetFunction(transform: DateTimezoneUtcNormalInstanceTransformType): MapFunction<Date, Milliseconds>;
|
|
162
173
|
targetDateToBaseDateOffset(date: Date): Milliseconds;
|
|
163
174
|
baseDateToTargetDateOffset(date: Date): Milliseconds;
|