@siemens/element-ng 47.12.1 → 47.12.2
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/datepicker/date-time-helper.d.ts +3 -2
- package/fesm2022/siemens-element-ng-datepicker.mjs +13 -7
- package/fesm2022/siemens-element-ng-datepicker.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-tree-view.mjs +2 -3
- package/fesm2022/siemens-element-ng-tree-view.mjs.map +1 -1
- package/package.json +7 -7
- package/tree-view/si-tree-view-item/si-tree-view-item.component.d.ts +0 -1
|
@@ -33,8 +33,9 @@ export declare const getDayStrings: (locale: string, weekStart?: WeekStart, form
|
|
|
33
33
|
*/
|
|
34
34
|
export declare const getFirstDayInMonth: (year: number, month: number) => Date;
|
|
35
35
|
/**
|
|
36
|
-
*
|
|
37
|
-
*
|
|
36
|
+
* Returns the ISO-8601 week number for the user's week containing the specified date.
|
|
37
|
+
* ISO-8601 weeks always start on Monday. When the user's week starts on Sunday or Saturday,
|
|
38
|
+
* the date is adjusted to find the corresponding ISO week (based on the Thursday rule).
|
|
38
39
|
* The first week of a year is the week that contains the first Thursday of the year (='First 4-day week').
|
|
39
40
|
* The highest week number in a year is either 52 or 53.
|
|
40
41
|
*
|
|
@@ -91,8 +91,9 @@ const getDayStrings = (locale, weekStart = 'monday', format = 'short') => {
|
|
|
91
91
|
*/
|
|
92
92
|
const getFirstDayInMonth = (year, month) => new Date(year, month - 1, 1);
|
|
93
93
|
/**
|
|
94
|
-
*
|
|
95
|
-
*
|
|
94
|
+
* Returns the ISO-8601 week number for the user's week containing the specified date.
|
|
95
|
+
* ISO-8601 weeks always start on Monday. When the user's week starts on Sunday or Saturday,
|
|
96
|
+
* the date is adjusted to find the corresponding ISO week (based on the Thursday rule).
|
|
96
97
|
* The first week of a year is the week that contains the first Thursday of the year (='First 4-day week').
|
|
97
98
|
* The highest week number in a year is either 52 or 53.
|
|
98
99
|
*
|
|
@@ -101,16 +102,21 @@ const getFirstDayInMonth = (year, month) => new Date(year, month - 1, 1);
|
|
|
101
102
|
* @returns The number of the Week
|
|
102
103
|
*/
|
|
103
104
|
const getWeekOfYear = (date, weekStart) => {
|
|
104
|
-
// Algorithm rewritten from C# example given at http://en.wikipedia.org/wiki/Talk:ISO_week_date
|
|
105
|
-
const dayOfWeek = getWeekDayOffset(date, weekStart) + 1;
|
|
106
105
|
const nearestThu = new Date(date);
|
|
107
|
-
nearestThu.
|
|
106
|
+
nearestThu.setHours(0, 0, 0, 0);
|
|
107
|
+
const offset = weekStart === 'monday' ? 0 : weekStart === 'sunday' ? 1 : 2;
|
|
108
|
+
nearestThu.setDate(nearestThu.getDate() + offset);
|
|
109
|
+
adjustToThursday(nearestThu);
|
|
108
110
|
const year = nearestThu.getFullYear();
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
+
const weekOne = new Date(year, 0, 4);
|
|
112
|
+
adjustToThursday(weekOne);
|
|
113
|
+
const days = Math.round((nearestThu.getTime() - weekOne.getTime()) / UNITS.millisecondsPerDay);
|
|
111
114
|
const week = 1 + Math.floor(days / UNITS.daysPerWeek); // Count of Thursdays
|
|
112
115
|
return week;
|
|
113
116
|
};
|
|
117
|
+
const adjustToThursday = (date) => {
|
|
118
|
+
date.setDate(date.getDate() + 3 - ((date.getDay() + 6) % 7));
|
|
119
|
+
};
|
|
114
120
|
const getWeekDayOffset = (date, weekStart) => {
|
|
115
121
|
const offset = WEEK_START_OFFSET[weekStart ?? 'monday'];
|
|
116
122
|
return (date.getDay() + 6 - offset) % 7;
|