@adobe/spacecat-shared-utils 1.76.0 → 1.77.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.
- package/CHANGELOG.md +7 -0
- package/package.json +1 -1
- package/src/calendar-week-helper.js +34 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [@adobe/spacecat-shared-utils-v1.77.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-utils-v1.76.0...@adobe/spacecat-shared-utils-v1.77.0) (2025-11-20)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* utils function getTemporalCondition extended ([#1155](https://github.com/adobe/spacecat-shared/issues/1155)) ([aad2d1c](https://github.com/adobe/spacecat-shared/commit/aad2d1c7229e98c7e45f07a541c81c1d4cf7c0c4))
|
|
7
|
+
|
|
1
8
|
# [@adobe/spacecat-shared-utils-v1.76.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-utils-v1.75.0...@adobe/spacecat-shared-utils-v1.76.0) (2025-11-20)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
|
@@ -202,10 +202,43 @@ export function getMonthInfo(inputMonth = null, inputYear = null) {
|
|
|
202
202
|
}
|
|
203
203
|
|
|
204
204
|
// --- Public: Main decision function ---
|
|
205
|
-
export function getTemporalCondition({
|
|
205
|
+
export function getTemporalCondition({
|
|
206
|
+
week,
|
|
207
|
+
month,
|
|
208
|
+
year,
|
|
209
|
+
numSeries = 1,
|
|
210
|
+
} = {}) {
|
|
206
211
|
const hasWeek = Number.isInteger(week) && Number.isInteger(year);
|
|
207
212
|
const hasMonth = Number.isInteger(month) && Number.isInteger(year);
|
|
208
213
|
|
|
214
|
+
if (numSeries > 1) {
|
|
215
|
+
if (!hasWeek && !hasMonth) {
|
|
216
|
+
throw new Error('Missing required parameters: week or month');
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
const conditions = [];
|
|
220
|
+
for (let i = 0; i < numSeries; i += 1) {
|
|
221
|
+
if (hasWeek) {
|
|
222
|
+
let currentWeek = week - i;
|
|
223
|
+
let currentYear = year;
|
|
224
|
+
if (currentWeek < 1) {
|
|
225
|
+
currentWeek = has53CalendarWeeks(currentYear) ? 53 : 52;
|
|
226
|
+
currentYear -= 1;
|
|
227
|
+
}
|
|
228
|
+
conditions.push(getWeekInfo(currentWeek, currentYear).temporalCondition);
|
|
229
|
+
} else if (hasMonth) {
|
|
230
|
+
let currentMonth = month - i;
|
|
231
|
+
let currentYear = year;
|
|
232
|
+
if (currentMonth < 1) {
|
|
233
|
+
currentMonth = 12;
|
|
234
|
+
currentYear -= 1;
|
|
235
|
+
}
|
|
236
|
+
conditions.push(getMonthInfo(currentMonth, currentYear).temporalCondition);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
return conditions.join(' OR ');
|
|
240
|
+
}
|
|
241
|
+
|
|
209
242
|
if (hasWeek && isValidWeek(week, year)) {
|
|
210
243
|
return getWeekInfo(week, year).temporalCondition;
|
|
211
244
|
}
|