aotrautils-srv 0.0.985 → 0.0.986
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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
/*utils COMMONS library associated with aotra version : «1_29072022-2359 (
|
|
3
|
+
/*utils COMMONS library associated with aotra version : «1_29072022-2359 (09/06/2024-04:10:35)»*/
|
|
4
4
|
/*-----------------------------------------------------------------------------*/
|
|
5
5
|
|
|
6
6
|
|
|
@@ -2215,6 +2215,56 @@ window.compareDates=function(date1=null,date2=null){
|
|
|
2215
2215
|
}
|
|
2216
2216
|
|
|
2217
2217
|
|
|
2218
|
+
window.getRandomDateFormattedString=function(daysSpan=365,format="ddMMYYYY") {
|
|
2219
|
+
const newDate=getRandomDate(daysSpan);
|
|
2220
|
+
const result=formatDate(newDate,format);
|
|
2221
|
+
return result;
|
|
2222
|
+
}
|
|
2223
|
+
|
|
2224
|
+
window.getRandomDate=function(spansRangeDays=365, spansRangeMonths=0, spansRangeYears=0, referenceDate=new Date()) {
|
|
2225
|
+
const start=new Date(referenceDate);
|
|
2226
|
+
const end=new Date(referenceDate);
|
|
2227
|
+
|
|
2228
|
+
if(spansRangeDays){
|
|
2229
|
+
const HALF_SPAN_DAYS=Math.round(spansRangeDays/2);
|
|
2230
|
+
start.setDate(referenceDate.getDate()-HALF_SPAN_DAYS);
|
|
2231
|
+
end.setDate(referenceDate.getDate()+HALF_SPAN_DAYS);
|
|
2232
|
+
}else if(spansRangeMonths){
|
|
2233
|
+
const HALF_SPAN_MONTHS=Math.round(spansRangMonthse/2);
|
|
2234
|
+
start.setMonths(referenceDate.getMonths()-HALF_SPAN_MONTHS);
|
|
2235
|
+
end.setMonths(referenceDate.getMonths()+HALF_SPAN_MONTHS);
|
|
2236
|
+
}if(spansRangeYears){
|
|
2237
|
+
const HALF_SPAN_YEARS=Math.round(spansRangeYears/2);
|
|
2238
|
+
start.setFullYear(referenceDate.getFullYear()-HALF_SPAN_YEARS);
|
|
2239
|
+
end.setFullYear(referenceDate.getFullYear()+HALF_SPAN_YEARS);
|
|
2240
|
+
}
|
|
2241
|
+
|
|
2242
|
+
return getRandomDateInPeriod(start, end);
|
|
2243
|
+
}
|
|
2244
|
+
|
|
2245
|
+
window.getRandomDateInPeriod=function(start, end) {
|
|
2246
|
+
// Generate a random date between start and end
|
|
2247
|
+
const deltaTime= end.getTime() - start.getTime();
|
|
2248
|
+
return new Date(start.getTime() + Math.random() * deltaTime);
|
|
2249
|
+
}
|
|
2250
|
+
|
|
2251
|
+
window.formatDate=function(date, format) {
|
|
2252
|
+
// Extract parts of the date
|
|
2253
|
+
const day = String(date.getDate()).padStart(2, "0");
|
|
2254
|
+
const month = String(date.getMonth() + 1).padStart(2, "0"); // Months are 0-based
|
|
2255
|
+
const year = date.getFullYear();
|
|
2256
|
+
const hours = String(date.getHours()).padStart(2, "0");
|
|
2257
|
+
const minutes = String(date.getMinutes()).padStart(2, "0");
|
|
2258
|
+
const seconds = String(date.getSeconds()).padStart(2, "0");
|
|
2259
|
+
// Replace placeholders in the format string
|
|
2260
|
+
return format.replace("dd", day)
|
|
2261
|
+
.replace("MM", month)
|
|
2262
|
+
.replace("yyyy", year)
|
|
2263
|
+
.replace("HH", hours)
|
|
2264
|
+
.replace("mm", minutes)
|
|
2265
|
+
.replace("ss", seconds);
|
|
2266
|
+
}
|
|
2267
|
+
|
|
2218
2268
|
|
|
2219
2269
|
// ==================== Strings management ====================
|
|
2220
2270
|
|
|
@@ -5297,7 +5347,7 @@ AOTRAUTILS_LIB_IS_LOADED=true;
|
|
|
5297
5347
|
|
|
5298
5348
|
|
|
5299
5349
|
|
|
5300
|
-
/*utils SERVER library associated with aotra version : «1_29072022-2359 (
|
|
5350
|
+
/*utils SERVER library associated with aotra version : «1_29072022-2359 (09/06/2024-04:10:35)»*/
|
|
5301
5351
|
/*-----------------------------------------------------------------------------*/
|
|
5302
5352
|
|
|
5303
5353
|
|
aotrautils-srv/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aotrautils-srv",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.986",
|
|
4
4
|
"main": "aotrautils-srv.build.js",
|
|
5
5
|
"description": "A library for vanilla javascript utils (server-side) used in aotra javascript CMS",
|
|
6
6
|
"author": "Jeremie Ratomposon <info@alqemia.com> (https://alqemia.com)",
|