@bbn/bbn 1.0.469 → 1.0.470
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/bbn.js +1 -1
- package/dist/bbn.js.map +1 -1
- package/dist/date.d.ts +7 -0
- package/dist/date.js +20 -0
- package/package.json +1 -1
package/dist/date.d.ts
CHANGED
|
@@ -9,6 +9,13 @@ declare class bbnDateTool {
|
|
|
9
9
|
minutes(v?: number): number | bbnDateTool;
|
|
10
10
|
seconds(v?: number): number | bbnDateTool;
|
|
11
11
|
weekday(v?: number, past?: boolean): number | bbnDateTool;
|
|
12
|
+
/**
|
|
13
|
+
* Returns the ISO-8601 week number of this date.
|
|
14
|
+
* Week starts on Monday, and week 1 is the week with Jan 4.
|
|
15
|
+
*
|
|
16
|
+
* @returns {number} ISO week number (1–53)
|
|
17
|
+
*/
|
|
18
|
+
week(): number;
|
|
12
19
|
get tst(): number;
|
|
13
20
|
get mtst(): number;
|
|
14
21
|
get YYYY(): string;
|
package/dist/date.js
CHANGED
|
@@ -309,6 +309,26 @@ class bbnDateTool {
|
|
|
309
309
|
}
|
|
310
310
|
return __classPrivateFieldGet(this, _bbnDateTool_value, "f").getDay();
|
|
311
311
|
}
|
|
312
|
+
/**
|
|
313
|
+
* Returns the ISO-8601 week number of this date.
|
|
314
|
+
* Week starts on Monday, and week 1 is the week with Jan 4.
|
|
315
|
+
*
|
|
316
|
+
* @returns {number} ISO week number (1–53)
|
|
317
|
+
*/
|
|
318
|
+
week() {
|
|
319
|
+
// Copy date in UTC to avoid timezone issues
|
|
320
|
+
const d = new Date(Date.UTC(this.year(), this.month() - 1, this.day()));
|
|
321
|
+
// Set to nearest Thursday (ISO anchor)
|
|
322
|
+
// (Thursday = day 4, because Sunday=0, Monday=1,...)
|
|
323
|
+
const dayNum = d.getUTCDay() || 7; // make Sunday = 7
|
|
324
|
+
// Move date to Thursday of this week
|
|
325
|
+
d.setUTCDate(d.getUTCDate() + (4 - dayNum));
|
|
326
|
+
// First week of the year is the week with Jan 4 in it
|
|
327
|
+
const yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
|
|
328
|
+
// Calculate full weeks between the dates
|
|
329
|
+
const weekNo = Math.ceil(((d.getTime() - yearStart.getTime()) / 86400000 + 1) / 7);
|
|
330
|
+
return weekNo;
|
|
331
|
+
}
|
|
312
332
|
get tst() {
|
|
313
333
|
return Math.ceil(__classPrivateFieldGet(this, _bbnDateTool_value, "f").getTime() / 1000);
|
|
314
334
|
}
|