funda-ui 4.7.740 → 4.7.750
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/Date/index.js +139 -12
- package/EventCalendar/index.js +139 -12
- package/EventCalendarTimeline/index.js +203 -22
- package/Utils/date.d.ts +35 -7
- package/Utils/date.js +133 -12
- package/lib/cjs/Date/index.js +139 -12
- package/lib/cjs/EventCalendar/index.js +139 -12
- package/lib/cjs/EventCalendarTimeline/index.js +203 -22
- package/lib/cjs/Utils/date.d.ts +35 -7
- package/lib/cjs/Utils/date.js +133 -12
- package/lib/esm/EventCalendarTimeline/index.tsx +70 -14
- package/lib/esm/Utils/libs/date.ts +152 -21
- package/package.json +1 -1
package/Date/index.js
CHANGED
|
@@ -2588,6 +2588,10 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
2588
2588
|
return (/* binding */_getPrevYearDate
|
|
2589
2589
|
);
|
|
2590
2590
|
},
|
|
2591
|
+
/* harmony export */"getSpecialDateEnd": function getSpecialDateEnd() {
|
|
2592
|
+
return (/* binding */_getSpecialDateEnd
|
|
2593
|
+
);
|
|
2594
|
+
},
|
|
2591
2595
|
/* harmony export */"getSpecifiedDate": function getSpecifiedDate() {
|
|
2592
2596
|
return (/* binding */_getSpecifiedDate
|
|
2593
2597
|
);
|
|
@@ -2600,6 +2604,10 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
2600
2604
|
return (/* binding */_getTomorrowDate
|
|
2601
2605
|
);
|
|
2602
2606
|
},
|
|
2607
|
+
/* harmony export */"getWeekDatesByDate": function getWeekDatesByDate() {
|
|
2608
|
+
return (/* binding */_getWeekDatesByDate
|
|
2609
|
+
);
|
|
2610
|
+
},
|
|
2603
2611
|
/* harmony export */"getWeekDatesFromMon": function getWeekDatesFromMon() {
|
|
2604
2612
|
return (/* binding */_getWeekDatesFromMon
|
|
2605
2613
|
);
|
|
@@ -2662,6 +2670,47 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
2662
2670
|
}
|
|
2663
2671
|
/* harmony export */
|
|
2664
2672
|
});
|
|
2673
|
+
/**
|
|
2674
|
+
* Get the Sunday of the week of the specific date, and return to the
|
|
2675
|
+
* end of January next year if it is New Year's Eve
|
|
2676
|
+
* @param {Date | String} v
|
|
2677
|
+
* @returns {String} yyyy-MM-dd
|
|
2678
|
+
*
|
|
2679
|
+
* @example
|
|
2680
|
+
* getSpecialDateEnd('2025-12-29'); // 2026-01-31
|
|
2681
|
+
* getSpecialDateEnd('2025-12-17'); // 2025-12-31
|
|
2682
|
+
*/
|
|
2683
|
+
/**
|
|
2684
|
+
* Calculates a special end date based on the week and month logic.
|
|
2685
|
+
* @param v - The input date (Date object, string, or timestamp)
|
|
2686
|
+
* @returns A formatted date string (YYYY-MM-DD)
|
|
2687
|
+
*/
|
|
2688
|
+
function _getSpecialDateEnd(v) {
|
|
2689
|
+
// Assuming dateFormat returns a Date object based on your logic
|
|
2690
|
+
var date = new Date(v);
|
|
2691
|
+
|
|
2692
|
+
// getWeekDatesByDate should return Date[]
|
|
2693
|
+
var weekDates = _getWeekDatesByDate(v);
|
|
2694
|
+
var sunday = weekDates[6]; // Sunday of that week
|
|
2695
|
+
|
|
2696
|
+
// If Sunday of this week rolls into the next year
|
|
2697
|
+
if (sunday.getFullYear() > date.getFullYear()) {
|
|
2698
|
+
var year = sunday.getFullYear();
|
|
2699
|
+
|
|
2700
|
+
// Get the last day of January of that new year
|
|
2701
|
+
// Note: month 1 in 'new Date' is February, day 0 gives the last day of Jan
|
|
2702
|
+
var lastDay = new Date(year, 1, 0).getDate();
|
|
2703
|
+
|
|
2704
|
+
// Using template literals for the return string
|
|
2705
|
+
return "".concat(year, "-01-").concat(lastDay.toString().padStart(2, '0'));
|
|
2706
|
+
}
|
|
2707
|
+
|
|
2708
|
+
// Default: Return the last day of the current month
|
|
2709
|
+
// We create a date for the "0th" day of the next month to get the end of current month
|
|
2710
|
+
var endOfCurrentMonth = new Date(date.getFullYear(), date.getMonth() + 1, 0);
|
|
2711
|
+
return _getCalendarDate(endOfCurrentMonth);
|
|
2712
|
+
}
|
|
2713
|
+
|
|
2665
2714
|
/**
|
|
2666
2715
|
* The check string contains only hours, minutes, and seconds
|
|
2667
2716
|
* @returns {Boolean}
|
|
@@ -3117,19 +3166,40 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
3117
3166
|
}
|
|
3118
3167
|
|
|
3119
3168
|
/**
|
|
3120
|
-
* Get
|
|
3121
|
-
* @param {Number} weekOffset
|
|
3122
|
-
*
|
|
3169
|
+
* Get all 7 dates for a specific week starting from Sunday.
|
|
3170
|
+
* * @param {Number} weekOffset - The offset of weeks from the current week.
|
|
3171
|
+
* 0: Current week
|
|
3172
|
+
* -1: Previous week
|
|
3173
|
+
* 1: Next week
|
|
3174
|
+
* @returns {Array<Date>} - An array containing 7 Date objects from Sunday to Saturday.
|
|
3123
3175
|
*/
|
|
3176
|
+
/*
|
|
3177
|
+
// Demo 1: Get dates for the current week (Sunday Start)
|
|
3178
|
+
const currentWeekSun = getWeekDatesFromSun(0);
|
|
3179
|
+
console.log('Sunday (Start):', currentWeekSun[0].toLocaleDateString());
|
|
3180
|
+
console.log('Saturday (End):', currentWeekSun[6].toLocaleDateString());
|
|
3181
|
+
|
|
3182
|
+
// Demo 2: Get the date range for the previous week
|
|
3183
|
+
const lastWeek = getWeekDatesFromSun(-1);
|
|
3184
|
+
const rangeStart = lastWeek[0].toISOString().split('T')[0];
|
|
3185
|
+
const rangeEnd = lastWeek[6].toISOString().split('T')[0];
|
|
3186
|
+
console.log(`Previous Week Range: ${rangeStart} to ${rangeEnd}`);
|
|
3187
|
+
|
|
3188
|
+
// Demo 3: Checking for Month/Year transitions
|
|
3189
|
+
const transitionWeek = getWeekDatesFromSun(0).map(d => d.toDateString());
|
|
3190
|
+
console.log('Transition Week Dates:', transitionWeek);
|
|
3191
|
+
|
|
3192
|
+
*/
|
|
3124
3193
|
function _getWeekDatesFromSun(weekOffset) {
|
|
3125
3194
|
var dates = [];
|
|
3195
|
+
// Start with a clean date (midnight) to avoid timezone/DST shifts during calculation
|
|
3126
3196
|
var currentDate = new Date();
|
|
3197
|
+
currentDate.setHours(0, 0, 0, 0);
|
|
3198
|
+
var dayOfWeek = currentDate.getDay();
|
|
3127
3199
|
|
|
3128
|
-
//
|
|
3129
|
-
|
|
3200
|
+
// Move to the Sunday of the current week, then apply the week offset
|
|
3201
|
+
// Formula: Current Date - Current Day Index + (Offset * 7)
|
|
3130
3202
|
currentDate.setDate(currentDate.getDate() - dayOfWeek + weekOffset * 7);
|
|
3131
|
-
|
|
3132
|
-
// Get the date of the week
|
|
3133
3203
|
for (var i = 0; i < 7; i++) {
|
|
3134
3204
|
var date = new Date(currentDate);
|
|
3135
3205
|
date.setDate(currentDate.getDate() + i);
|
|
@@ -3139,20 +3209,46 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
3139
3209
|
}
|
|
3140
3210
|
|
|
3141
3211
|
/**
|
|
3142
|
-
* Get
|
|
3143
|
-
* @param {Number} weekOffset
|
|
3144
|
-
*
|
|
3212
|
+
* Get all 7 dates for a specific week starting from Monday.
|
|
3213
|
+
* * @param {Number} weekOffset - The offset of weeks from the current week.
|
|
3214
|
+
* 0: Current week
|
|
3215
|
+
* -1: Previous week
|
|
3216
|
+
* 1: Next week
|
|
3217
|
+
* @returns {Array<Date>} - An array containing 7 Date objects from Monday to Sunday.
|
|
3145
3218
|
*/
|
|
3219
|
+
/*
|
|
3220
|
+
// Demo 1: Get dates for the current week
|
|
3221
|
+
const currentWeek = getWeekDatesFromMon(0);
|
|
3222
|
+
console.log('Monday of this week:', currentWeek[0].toLocaleDateString());
|
|
3223
|
+
console.log('Sunday of this week:', currentWeek[6].toLocaleDateString());
|
|
3224
|
+
|
|
3225
|
+
// Demo 2: Get dates for the next week
|
|
3226
|
+
const nextWeek = getWeekDatesFromMon(1);
|
|
3227
|
+
console.log('Monday of next week:', nextWeek[0].toLocaleDateString());
|
|
3228
|
+
|
|
3229
|
+
// Demo 3: Format the output as YYYY-MM-DD
|
|
3230
|
+
const formattedWeek = getWeekDatesFromMon(0).map(date => {
|
|
3231
|
+
const y = date.getFullYear();
|
|
3232
|
+
const m = String(date.getMonth() + 1).padStart(2, '0');
|
|
3233
|
+
const d = String(date.getDate()).padStart(2, '0');
|
|
3234
|
+
return `${y}-${m}-${d}`;
|
|
3235
|
+
});
|
|
3236
|
+
console.log('Formatted Week Array:', formattedWeek);
|
|
3237
|
+
// Result: ["2025-12-29", "2025-12-30", ..., "2026-01-04"]
|
|
3238
|
+
*/
|
|
3146
3239
|
function _getWeekDatesFromMon(weekOffset) {
|
|
3147
3240
|
var dates = [];
|
|
3148
3241
|
var currentDate = new Date();
|
|
3149
3242
|
|
|
3150
|
-
//
|
|
3243
|
+
// Calculate the difference to get to Monday of the current week
|
|
3244
|
+
// If today is Sunday (0), we go back 6 days. Otherwise, go to (1 - currentDay).
|
|
3151
3245
|
var dayOfWeek = currentDate.getDay();
|
|
3152
3246
|
var diffToMonday = dayOfWeek === 0 ? -6 : 1 - dayOfWeek;
|
|
3247
|
+
|
|
3248
|
+
// Apply the Monday offset and the week offset (7 days per week)
|
|
3153
3249
|
currentDate.setDate(currentDate.getDate() + diffToMonday + weekOffset * 7);
|
|
3154
3250
|
|
|
3155
|
-
//
|
|
3251
|
+
// Generate the 7 days of the week
|
|
3156
3252
|
for (var i = 0; i < 7; i++) {
|
|
3157
3253
|
var date = new Date(currentDate);
|
|
3158
3254
|
date.setDate(currentDate.getDate() + i);
|
|
@@ -3161,6 +3257,37 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
3161
3257
|
return dates;
|
|
3162
3258
|
}
|
|
3163
3259
|
|
|
3260
|
+
/**
|
|
3261
|
+
* Get the date list of the week for the specified date (starting from Monday)
|
|
3262
|
+
* @param {Date | String} v - The specified date
|
|
3263
|
+
* @returns {Array<Date>} - An array containing 7 Date objects
|
|
3264
|
+
*/
|
|
3265
|
+
function _getWeekDatesByDate(v) {
|
|
3266
|
+
var dates = [];
|
|
3267
|
+
|
|
3268
|
+
// Ensure we are working with a Date object.
|
|
3269
|
+
// If 'dateFormat' was a custom utility in your JS, replace 'new Date(v)' with that utility.
|
|
3270
|
+
var currentDate = new Date(v);
|
|
3271
|
+
|
|
3272
|
+
// Get the day of the week (0 for Sunday, 1 for Monday, ..., 6 for Saturday)
|
|
3273
|
+
var dayOfWeek = currentDate.getDay();
|
|
3274
|
+
|
|
3275
|
+
// Calculate difference to Monday: if Sunday (0) subtract 6 days, otherwise subtract (day - 1)
|
|
3276
|
+
var diffToMonday = dayOfWeek === 0 ? -6 : 1 - dayOfWeek;
|
|
3277
|
+
|
|
3278
|
+
// Create the Monday starting point
|
|
3279
|
+
var monday = new Date(currentDate);
|
|
3280
|
+
monday.setDate(currentDate.getDate() + diffToMonday);
|
|
3281
|
+
|
|
3282
|
+
// Generate the 7 days of the week
|
|
3283
|
+
for (var i = 0; i < 7; i++) {
|
|
3284
|
+
var date = new Date(monday);
|
|
3285
|
+
date.setDate(monday.getDate() + i);
|
|
3286
|
+
dates.push(date);
|
|
3287
|
+
}
|
|
3288
|
+
return dates;
|
|
3289
|
+
}
|
|
3290
|
+
|
|
3164
3291
|
/******/
|
|
3165
3292
|
return __webpack_exports__;
|
|
3166
3293
|
/******/
|
package/EventCalendar/index.js
CHANGED
|
@@ -2216,6 +2216,10 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
2216
2216
|
return (/* binding */_getPrevYearDate
|
|
2217
2217
|
);
|
|
2218
2218
|
},
|
|
2219
|
+
/* harmony export */"getSpecialDateEnd": function getSpecialDateEnd() {
|
|
2220
|
+
return (/* binding */_getSpecialDateEnd
|
|
2221
|
+
);
|
|
2222
|
+
},
|
|
2219
2223
|
/* harmony export */"getSpecifiedDate": function getSpecifiedDate() {
|
|
2220
2224
|
return (/* binding */_getSpecifiedDate
|
|
2221
2225
|
);
|
|
@@ -2228,6 +2232,10 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
2228
2232
|
return (/* binding */_getTomorrowDate
|
|
2229
2233
|
);
|
|
2230
2234
|
},
|
|
2235
|
+
/* harmony export */"getWeekDatesByDate": function getWeekDatesByDate() {
|
|
2236
|
+
return (/* binding */_getWeekDatesByDate
|
|
2237
|
+
);
|
|
2238
|
+
},
|
|
2231
2239
|
/* harmony export */"getWeekDatesFromMon": function getWeekDatesFromMon() {
|
|
2232
2240
|
return (/* binding */_getWeekDatesFromMon
|
|
2233
2241
|
);
|
|
@@ -2290,6 +2298,47 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
2290
2298
|
}
|
|
2291
2299
|
/* harmony export */
|
|
2292
2300
|
});
|
|
2301
|
+
/**
|
|
2302
|
+
* Get the Sunday of the week of the specific date, and return to the
|
|
2303
|
+
* end of January next year if it is New Year's Eve
|
|
2304
|
+
* @param {Date | String} v
|
|
2305
|
+
* @returns {String} yyyy-MM-dd
|
|
2306
|
+
*
|
|
2307
|
+
* @example
|
|
2308
|
+
* getSpecialDateEnd('2025-12-29'); // 2026-01-31
|
|
2309
|
+
* getSpecialDateEnd('2025-12-17'); // 2025-12-31
|
|
2310
|
+
*/
|
|
2311
|
+
/**
|
|
2312
|
+
* Calculates a special end date based on the week and month logic.
|
|
2313
|
+
* @param v - The input date (Date object, string, or timestamp)
|
|
2314
|
+
* @returns A formatted date string (YYYY-MM-DD)
|
|
2315
|
+
*/
|
|
2316
|
+
function _getSpecialDateEnd(v) {
|
|
2317
|
+
// Assuming dateFormat returns a Date object based on your logic
|
|
2318
|
+
var date = new Date(v);
|
|
2319
|
+
|
|
2320
|
+
// getWeekDatesByDate should return Date[]
|
|
2321
|
+
var weekDates = _getWeekDatesByDate(v);
|
|
2322
|
+
var sunday = weekDates[6]; // Sunday of that week
|
|
2323
|
+
|
|
2324
|
+
// If Sunday of this week rolls into the next year
|
|
2325
|
+
if (sunday.getFullYear() > date.getFullYear()) {
|
|
2326
|
+
var year = sunday.getFullYear();
|
|
2327
|
+
|
|
2328
|
+
// Get the last day of January of that new year
|
|
2329
|
+
// Note: month 1 in 'new Date' is February, day 0 gives the last day of Jan
|
|
2330
|
+
var lastDay = new Date(year, 1, 0).getDate();
|
|
2331
|
+
|
|
2332
|
+
// Using template literals for the return string
|
|
2333
|
+
return "".concat(year, "-01-").concat(lastDay.toString().padStart(2, '0'));
|
|
2334
|
+
}
|
|
2335
|
+
|
|
2336
|
+
// Default: Return the last day of the current month
|
|
2337
|
+
// We create a date for the "0th" day of the next month to get the end of current month
|
|
2338
|
+
var endOfCurrentMonth = new Date(date.getFullYear(), date.getMonth() + 1, 0);
|
|
2339
|
+
return _getCalendarDate(endOfCurrentMonth);
|
|
2340
|
+
}
|
|
2341
|
+
|
|
2293
2342
|
/**
|
|
2294
2343
|
* The check string contains only hours, minutes, and seconds
|
|
2295
2344
|
* @returns {Boolean}
|
|
@@ -2745,19 +2794,40 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
2745
2794
|
}
|
|
2746
2795
|
|
|
2747
2796
|
/**
|
|
2748
|
-
* Get
|
|
2749
|
-
* @param {Number} weekOffset
|
|
2750
|
-
*
|
|
2797
|
+
* Get all 7 dates for a specific week starting from Sunday.
|
|
2798
|
+
* * @param {Number} weekOffset - The offset of weeks from the current week.
|
|
2799
|
+
* 0: Current week
|
|
2800
|
+
* -1: Previous week
|
|
2801
|
+
* 1: Next week
|
|
2802
|
+
* @returns {Array<Date>} - An array containing 7 Date objects from Sunday to Saturday.
|
|
2751
2803
|
*/
|
|
2804
|
+
/*
|
|
2805
|
+
// Demo 1: Get dates for the current week (Sunday Start)
|
|
2806
|
+
const currentWeekSun = getWeekDatesFromSun(0);
|
|
2807
|
+
console.log('Sunday (Start):', currentWeekSun[0].toLocaleDateString());
|
|
2808
|
+
console.log('Saturday (End):', currentWeekSun[6].toLocaleDateString());
|
|
2809
|
+
|
|
2810
|
+
// Demo 2: Get the date range for the previous week
|
|
2811
|
+
const lastWeek = getWeekDatesFromSun(-1);
|
|
2812
|
+
const rangeStart = lastWeek[0].toISOString().split('T')[0];
|
|
2813
|
+
const rangeEnd = lastWeek[6].toISOString().split('T')[0];
|
|
2814
|
+
console.log(`Previous Week Range: ${rangeStart} to ${rangeEnd}`);
|
|
2815
|
+
|
|
2816
|
+
// Demo 3: Checking for Month/Year transitions
|
|
2817
|
+
const transitionWeek = getWeekDatesFromSun(0).map(d => d.toDateString());
|
|
2818
|
+
console.log('Transition Week Dates:', transitionWeek);
|
|
2819
|
+
|
|
2820
|
+
*/
|
|
2752
2821
|
function _getWeekDatesFromSun(weekOffset) {
|
|
2753
2822
|
var dates = [];
|
|
2823
|
+
// Start with a clean date (midnight) to avoid timezone/DST shifts during calculation
|
|
2754
2824
|
var currentDate = new Date();
|
|
2825
|
+
currentDate.setHours(0, 0, 0, 0);
|
|
2826
|
+
var dayOfWeek = currentDate.getDay();
|
|
2755
2827
|
|
|
2756
|
-
//
|
|
2757
|
-
|
|
2828
|
+
// Move to the Sunday of the current week, then apply the week offset
|
|
2829
|
+
// Formula: Current Date - Current Day Index + (Offset * 7)
|
|
2758
2830
|
currentDate.setDate(currentDate.getDate() - dayOfWeek + weekOffset * 7);
|
|
2759
|
-
|
|
2760
|
-
// Get the date of the week
|
|
2761
2831
|
for (var i = 0; i < 7; i++) {
|
|
2762
2832
|
var date = new Date(currentDate);
|
|
2763
2833
|
date.setDate(currentDate.getDate() + i);
|
|
@@ -2767,20 +2837,46 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
2767
2837
|
}
|
|
2768
2838
|
|
|
2769
2839
|
/**
|
|
2770
|
-
* Get
|
|
2771
|
-
* @param {Number} weekOffset
|
|
2772
|
-
*
|
|
2840
|
+
* Get all 7 dates for a specific week starting from Monday.
|
|
2841
|
+
* * @param {Number} weekOffset - The offset of weeks from the current week.
|
|
2842
|
+
* 0: Current week
|
|
2843
|
+
* -1: Previous week
|
|
2844
|
+
* 1: Next week
|
|
2845
|
+
* @returns {Array<Date>} - An array containing 7 Date objects from Monday to Sunday.
|
|
2773
2846
|
*/
|
|
2847
|
+
/*
|
|
2848
|
+
// Demo 1: Get dates for the current week
|
|
2849
|
+
const currentWeek = getWeekDatesFromMon(0);
|
|
2850
|
+
console.log('Monday of this week:', currentWeek[0].toLocaleDateString());
|
|
2851
|
+
console.log('Sunday of this week:', currentWeek[6].toLocaleDateString());
|
|
2852
|
+
|
|
2853
|
+
// Demo 2: Get dates for the next week
|
|
2854
|
+
const nextWeek = getWeekDatesFromMon(1);
|
|
2855
|
+
console.log('Monday of next week:', nextWeek[0].toLocaleDateString());
|
|
2856
|
+
|
|
2857
|
+
// Demo 3: Format the output as YYYY-MM-DD
|
|
2858
|
+
const formattedWeek = getWeekDatesFromMon(0).map(date => {
|
|
2859
|
+
const y = date.getFullYear();
|
|
2860
|
+
const m = String(date.getMonth() + 1).padStart(2, '0');
|
|
2861
|
+
const d = String(date.getDate()).padStart(2, '0');
|
|
2862
|
+
return `${y}-${m}-${d}`;
|
|
2863
|
+
});
|
|
2864
|
+
console.log('Formatted Week Array:', formattedWeek);
|
|
2865
|
+
// Result: ["2025-12-29", "2025-12-30", ..., "2026-01-04"]
|
|
2866
|
+
*/
|
|
2774
2867
|
function _getWeekDatesFromMon(weekOffset) {
|
|
2775
2868
|
var dates = [];
|
|
2776
2869
|
var currentDate = new Date();
|
|
2777
2870
|
|
|
2778
|
-
//
|
|
2871
|
+
// Calculate the difference to get to Monday of the current week
|
|
2872
|
+
// If today is Sunday (0), we go back 6 days. Otherwise, go to (1 - currentDay).
|
|
2779
2873
|
var dayOfWeek = currentDate.getDay();
|
|
2780
2874
|
var diffToMonday = dayOfWeek === 0 ? -6 : 1 - dayOfWeek;
|
|
2875
|
+
|
|
2876
|
+
// Apply the Monday offset and the week offset (7 days per week)
|
|
2781
2877
|
currentDate.setDate(currentDate.getDate() + diffToMonday + weekOffset * 7);
|
|
2782
2878
|
|
|
2783
|
-
//
|
|
2879
|
+
// Generate the 7 days of the week
|
|
2784
2880
|
for (var i = 0; i < 7; i++) {
|
|
2785
2881
|
var date = new Date(currentDate);
|
|
2786
2882
|
date.setDate(currentDate.getDate() + i);
|
|
@@ -2789,6 +2885,37 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
2789
2885
|
return dates;
|
|
2790
2886
|
}
|
|
2791
2887
|
|
|
2888
|
+
/**
|
|
2889
|
+
* Get the date list of the week for the specified date (starting from Monday)
|
|
2890
|
+
* @param {Date | String} v - The specified date
|
|
2891
|
+
* @returns {Array<Date>} - An array containing 7 Date objects
|
|
2892
|
+
*/
|
|
2893
|
+
function _getWeekDatesByDate(v) {
|
|
2894
|
+
var dates = [];
|
|
2895
|
+
|
|
2896
|
+
// Ensure we are working with a Date object.
|
|
2897
|
+
// If 'dateFormat' was a custom utility in your JS, replace 'new Date(v)' with that utility.
|
|
2898
|
+
var currentDate = new Date(v);
|
|
2899
|
+
|
|
2900
|
+
// Get the day of the week (0 for Sunday, 1 for Monday, ..., 6 for Saturday)
|
|
2901
|
+
var dayOfWeek = currentDate.getDay();
|
|
2902
|
+
|
|
2903
|
+
// Calculate difference to Monday: if Sunday (0) subtract 6 days, otherwise subtract (day - 1)
|
|
2904
|
+
var diffToMonday = dayOfWeek === 0 ? -6 : 1 - dayOfWeek;
|
|
2905
|
+
|
|
2906
|
+
// Create the Monday starting point
|
|
2907
|
+
var monday = new Date(currentDate);
|
|
2908
|
+
monday.setDate(currentDate.getDate() + diffToMonday);
|
|
2909
|
+
|
|
2910
|
+
// Generate the 7 days of the week
|
|
2911
|
+
for (var i = 0; i < 7; i++) {
|
|
2912
|
+
var date = new Date(monday);
|
|
2913
|
+
date.setDate(monday.getDate() + i);
|
|
2914
|
+
dates.push(date);
|
|
2915
|
+
}
|
|
2916
|
+
return dates;
|
|
2917
|
+
}
|
|
2918
|
+
|
|
2792
2919
|
/******/
|
|
2793
2920
|
return __webpack_exports__;
|
|
2794
2921
|
/******/
|