busroot-sdk 0.0.8-dev.2721287447 → 0.0.8-dev.2727678619
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/build/index.js +21 -19
- package/package.json +1 -1
package/build/index.js
CHANGED
|
@@ -1003,6 +1003,8 @@ var require_times = __commonJS({
|
|
|
1003
1003
|
exports2.getRangeFromSpecificHour = getRangeFromSpecificHour;
|
|
1004
1004
|
exports2.toSpecificHourString = toSpecificHourString;
|
|
1005
1005
|
exports2.fromSpecificHourString = fromSpecificHourString;
|
|
1006
|
+
exports2.plantWeekNumber = plantWeekNumber;
|
|
1007
|
+
exports2.plantWeekStart = plantWeekStart;
|
|
1006
1008
|
exports2.getTimeRangeFromRangeCode = getTimeRangeFromRangeCode;
|
|
1007
1009
|
exports2.getCoverage = getCoverage;
|
|
1008
1010
|
exports2.getWindowAtTime = getWindowAtTime;
|
|
@@ -1369,6 +1371,21 @@ var require_times = __commonJS({
|
|
|
1369
1371
|
hour: parseInt(parts[3])
|
|
1370
1372
|
};
|
|
1371
1373
|
}
|
|
1374
|
+
var WEEK_NUMBER_ANCHOR_OFFSET_DAYS = 3;
|
|
1375
|
+
function plantWeekNumber(weekStart) {
|
|
1376
|
+
const anchor = weekStart.clone().add(WEEK_NUMBER_ANCHOR_OFFSET_DAYS, "days");
|
|
1377
|
+
return { year: anchor.isoWeekYear(), week: anchor.isoWeek() };
|
|
1378
|
+
}
|
|
1379
|
+
function plantWeekStart(year, week, weekStartDay = 0, timezone) {
|
|
1380
|
+
const start = (timezone ? moment_timezone_1.default.tz(timezone) : (0, moment_timezone_1.default)()).isoWeekYear(year).isoWeek(week).startOf("isoWeek");
|
|
1381
|
+
if (weekStartDay > 0) {
|
|
1382
|
+
start.add(weekStartDay, "days");
|
|
1383
|
+
}
|
|
1384
|
+
if (weekStartDay > WEEK_NUMBER_ANCHOR_OFFSET_DAYS) {
|
|
1385
|
+
start.subtract(7, "days");
|
|
1386
|
+
}
|
|
1387
|
+
return start;
|
|
1388
|
+
}
|
|
1372
1389
|
function floorToPlantWeekStart(instant, plant) {
|
|
1373
1390
|
const weekStartDay = plant.weekStartDay ?? 0;
|
|
1374
1391
|
return (0, moment_timezone_1.default)(instant).tz(plant.timezone).subtract(weekStartDay, "days").subtract(plant.dayStartHour, "hours").startOf("isoWeek").add(weekStartDay, "days").add(plant.dayStartHour, "hours").valueOf();
|
|
@@ -1449,11 +1466,7 @@ var require_times = __commonJS({
|
|
|
1449
1466
|
return timestampsToTimeRange({ from: day.valueOf(), to: day.add(24, "hours").valueOf() });
|
|
1450
1467
|
},
|
|
1451
1468
|
week: () => {
|
|
1452
|
-
const week =
|
|
1453
|
-
const weekStartDay = plant.weekStartDay ?? 0;
|
|
1454
|
-
if (weekStartDay > 0) {
|
|
1455
|
-
week.add(weekStartDay, "days");
|
|
1456
|
-
}
|
|
1469
|
+
const week = plantWeekStart(parseInt(parts[1]), parseInt(parts[2]), plant.weekStartDay ?? 0, plant.timezone);
|
|
1457
1470
|
week.add(plant.dayStartHour, "hour");
|
|
1458
1471
|
week.utc();
|
|
1459
1472
|
return timestampsToTimeRange({ from: week.valueOf(), to: week.add(24 * 7, "hours").valueOf() });
|
|
@@ -1471,11 +1484,7 @@ var require_times = __commonJS({
|
|
|
1471
1484
|
const quarter = parseInt(parts[2]);
|
|
1472
1485
|
const weeks = getWeeksInQuarter(year, quarter);
|
|
1473
1486
|
const firstWeek = weeks[0];
|
|
1474
|
-
const start =
|
|
1475
|
-
const weekStartDay = plant.weekStartDay ?? 0;
|
|
1476
|
-
if (weekStartDay > 0) {
|
|
1477
|
-
start.add(weekStartDay, "days");
|
|
1478
|
-
}
|
|
1487
|
+
const start = plantWeekStart(year, firstWeek, plant.weekStartDay ?? 0, plant.timezone);
|
|
1479
1488
|
start.add(plant.dayStartHour, "hour");
|
|
1480
1489
|
start.utc();
|
|
1481
1490
|
return timestampsToTimeRange({ from: start.valueOf(), to: start.add(weeks.length * 7 * 24, "hours").valueOf() });
|
|
@@ -1484,11 +1493,7 @@ var require_times = __commonJS({
|
|
|
1484
1493
|
year: () => {
|
|
1485
1494
|
const year = parseInt(parts[1]);
|
|
1486
1495
|
const weeksInYear = (0, moment_timezone_1.default)({ year }).isoWeeksInISOWeekYear();
|
|
1487
|
-
const start =
|
|
1488
|
-
const weekStartDay = plant.weekStartDay ?? 0;
|
|
1489
|
-
if (weekStartDay > 0) {
|
|
1490
|
-
start.add(weekStartDay, "days");
|
|
1491
|
-
}
|
|
1496
|
+
const start = plantWeekStart(year, 1, plant.weekStartDay ?? 0, plant.timezone);
|
|
1492
1497
|
start.add(plant.dayStartHour, "hour");
|
|
1493
1498
|
start.utc();
|
|
1494
1499
|
return timestampsToTimeRange({ from: start.valueOf(), to: start.add(weeksInYear * 7 * 24, "hours").valueOf() });
|
|
@@ -1620,10 +1625,7 @@ var require_times = __commonJS({
|
|
|
1620
1625
|
}
|
|
1621
1626
|
function getDaysInWeek(year, weekNo, weekStartDay = 0, timezone) {
|
|
1622
1627
|
const days = [];
|
|
1623
|
-
const dayMoment = (
|
|
1624
|
-
if (weekStartDay > 0) {
|
|
1625
|
-
dayMoment.add(weekStartDay, "days");
|
|
1626
|
-
}
|
|
1628
|
+
const dayMoment = plantWeekStart(year, weekNo, weekStartDay, timezone);
|
|
1627
1629
|
for (let di = 0; di < 7; di++) {
|
|
1628
1630
|
days.push({
|
|
1629
1631
|
label: dayMoment.format("ddd, MMM DD"),
|
package/package.json
CHANGED