date-vir 9.2.1 → 9.3.0
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.
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type DayOfWeekName } from '@date-vir/duration';
|
|
2
|
+
import { type FullDate } from '../full-date/full-date-shape.js';
|
|
3
|
+
/**
|
|
4
|
+
* Get the day of the week that a {@link FullDate} falls on in its own timezone. To get the day of
|
|
5
|
+
* the week in a different timezone, convert the date first with `toNewTimezone`.
|
|
6
|
+
*
|
|
7
|
+
* @category Calculation
|
|
8
|
+
* @example
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* import {getDayOfWeek} from 'date-vir';
|
|
12
|
+
*
|
|
13
|
+
* getDayOfWeek({
|
|
14
|
+
* year: 2026,
|
|
15
|
+
* month: 10,
|
|
16
|
+
* day: 2,
|
|
17
|
+
*
|
|
18
|
+
* hour: 23,
|
|
19
|
+
* minute: 30,
|
|
20
|
+
* second: 0,
|
|
21
|
+
* millisecond: 0,
|
|
22
|
+
*
|
|
23
|
+
* timezone: 'America/Denver',
|
|
24
|
+
* }); // outputs `DayOfWeekName.Friday` (even though this is a Saturday in UTC)
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare function getDayOfWeek(date: Readonly<FullDate>): DayOfWeekName;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { dayOfWeekNameOrder } from '@date-vir/duration';
|
|
2
|
+
import { toLuxonDateTime } from '../full-date/luxon-date-time-conversion.js';
|
|
3
|
+
/**
|
|
4
|
+
* Get the day of the week that a {@link FullDate} falls on in its own timezone. To get the day of
|
|
5
|
+
* the week in a different timezone, convert the date first with `toNewTimezone`.
|
|
6
|
+
*
|
|
7
|
+
* @category Calculation
|
|
8
|
+
* @example
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* import {getDayOfWeek} from 'date-vir';
|
|
12
|
+
*
|
|
13
|
+
* getDayOfWeek({
|
|
14
|
+
* year: 2026,
|
|
15
|
+
* month: 10,
|
|
16
|
+
* day: 2,
|
|
17
|
+
*
|
|
18
|
+
* hour: 23,
|
|
19
|
+
* minute: 30,
|
|
20
|
+
* second: 0,
|
|
21
|
+
* millisecond: 0,
|
|
22
|
+
*
|
|
23
|
+
* timezone: 'America/Denver',
|
|
24
|
+
* }); // outputs `DayOfWeekName.Friday` (even though this is a Saturday in UTC)
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export function getDayOfWeek(date) {
|
|
28
|
+
return dayOfWeekNameOrder[(toLuxonDateTime(date).weekday % 7)];
|
|
29
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from './date-operations/calculate-relative-date.js';
|
|
2
2
|
export * from './date-operations/combine-dates.js';
|
|
3
3
|
export * from './date-operations/date-position.js';
|
|
4
|
+
export * from './date-operations/day-of-week.js';
|
|
4
5
|
export * from './date-operations/diff-dates.js';
|
|
5
6
|
export * from './duration-shape.js';
|
|
6
7
|
export * from './extra-utils/end.js';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from './date-operations/calculate-relative-date.js';
|
|
2
2
|
export * from './date-operations/combine-dates.js';
|
|
3
3
|
export * from './date-operations/date-position.js';
|
|
4
|
+
export * from './date-operations/day-of-week.js';
|
|
4
5
|
export * from './date-operations/diff-dates.js';
|
|
5
6
|
export * from './duration-shape.js';
|
|
6
7
|
export * from './extra-utils/end.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "date-vir",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.3.0",
|
|
4
4
|
"description": "Easy and explicit dates and times.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"date",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@augment-vir/assert": "^32.5.0",
|
|
39
39
|
"@augment-vir/common": "^32.5.0",
|
|
40
|
-
"@date-vir/duration": "^9.
|
|
40
|
+
"@date-vir/duration": "^9.3.0",
|
|
41
41
|
"@types/luxon": "^3.7.5",
|
|
42
42
|
"luxon": "^3.7.2",
|
|
43
43
|
"object-shape-tester": "^6.15.1",
|