@hkdigital/lib-core 0.5.44 → 0.5.46
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/dist/state/context/README.md +226 -0
- package/dist/state/context/RouteStateContext.svelte.d.ts +44 -0
- package/dist/state/context/RouteStateContext.svelte.js +119 -0
- package/dist/state/context.d.ts +2 -1
- package/dist/state/context.js +2 -1
- package/dist/state/machines/page-machine/PageMachine.svelte.d.ts +270 -0
- package/dist/state/machines/page-machine/PageMachine.svelte.js +537 -0
- package/dist/state/machines/page-machine/README.md +157 -0
- package/dist/state/machines.d.ts +1 -0
- package/dist/state/machines.js +2 -0
- package/dist/ui/components/game-box/ScaledContainer.svelte +1 -1
- package/dist/util/time/index.js +19 -8
- package/package.json +1 -1
- /package/dist/state/context/{state-context.d.ts → util.d.ts} +0 -0
- /package/dist/state/context/{state-context.js → util.js} +0 -0
package/dist/util/time/index.js
CHANGED
|
@@ -185,12 +185,16 @@ export function getWeekNumber(dateOrTimestamp) {
|
|
|
185
185
|
//
|
|
186
186
|
// Create a copy of this date object
|
|
187
187
|
//
|
|
188
|
-
const target = new Date(
|
|
188
|
+
const target = new Date(Date.UTC(
|
|
189
|
+
date.getUTCFullYear(),
|
|
190
|
+
date.getUTCMonth(),
|
|
191
|
+
date.getUTCDate()
|
|
192
|
+
));
|
|
189
193
|
|
|
190
194
|
//
|
|
191
195
|
// ISO week date weeks start on Monday, so correct the day number
|
|
192
196
|
//
|
|
193
|
-
const dayNumber = (date.
|
|
197
|
+
const dayNumber = (date.getUTCDay() + 6) % 7;
|
|
194
198
|
|
|
195
199
|
//
|
|
196
200
|
// ISO 8601 states that week 1 is the week with the first Thursday
|
|
@@ -198,22 +202,29 @@ export function getWeekNumber(dateOrTimestamp) {
|
|
|
198
202
|
//
|
|
199
203
|
// Set the target date to the Thursday in the target week
|
|
200
204
|
//
|
|
201
|
-
target.
|
|
205
|
+
target.setUTCDate(target.getUTCDate() - dayNumber + 3);
|
|
202
206
|
|
|
203
207
|
//
|
|
204
208
|
// Store the millisecond value of the target date
|
|
205
209
|
//
|
|
206
210
|
const firstThursday = target.valueOf();
|
|
207
211
|
|
|
208
|
-
//
|
|
209
|
-
//
|
|
210
|
-
|
|
212
|
+
//
|
|
213
|
+
// Get the year of the Thursday in the target week
|
|
214
|
+
// (This is important for dates near year boundaries)
|
|
215
|
+
//
|
|
216
|
+
const yearOfThursday = target.getUTCFullYear();
|
|
217
|
+
|
|
218
|
+
// Set the target to the first Thursday of that year
|
|
219
|
+
// First, set the target to January 1st of that year
|
|
220
|
+
target.setUTCFullYear(yearOfThursday);
|
|
221
|
+
target.setUTCMonth(0, 1);
|
|
211
222
|
|
|
212
223
|
//
|
|
213
224
|
// Not a Thursday? Correct the date to the next Thursday
|
|
214
225
|
//
|
|
215
|
-
if (target.
|
|
216
|
-
target.
|
|
226
|
+
if (target.getUTCDay() !== 4) {
|
|
227
|
+
target.setUTCMonth(0, 1 + ((4 - target.getUTCDay() + 7) % 7));
|
|
217
228
|
}
|
|
218
229
|
|
|
219
230
|
//
|
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|