tpmkms_4wp 9.3.0-beta.44 → 9.3.0-beta.46
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/common/dateTimeSelectors.js +6 -2
- package/common/dateTimeSelectors.test.json +55310 -0
- package/common/dates.instance.json +46 -95
- package/common/dates.js +9 -0
- package/common/dates.test.json +1796 -0
- package/common/helpers/dateTimeSelectors.js +54 -1
- package/common/reminders.test.json +3363 -0
- package/package.json +2 -2
@@ -30,6 +30,35 @@ function getNextDayOfWeek(date, targetDay) {
|
|
30
30
|
return nextDate;
|
31
31
|
}
|
32
32
|
|
33
|
+
function toMonthNumber(value) {
|
34
|
+
const map = {
|
35
|
+
"jan_dates": 1,
|
36
|
+
"feb_dates": 2,
|
37
|
+
"mar_dates": 3,
|
38
|
+
"apr_dates": 4,
|
39
|
+
"may_dates": 5,
|
40
|
+
"jun_dates": 6,
|
41
|
+
"jul_dates": 7,
|
42
|
+
"aug_dates": 8,
|
43
|
+
"sept_dates": 9,
|
44
|
+
"oct_dates": 10,
|
45
|
+
"nov_dates": 11,
|
46
|
+
"dec_dates": 12,
|
47
|
+
"january_dates": 1,
|
48
|
+
"february_dates": 2,
|
49
|
+
"march_dates": 3,
|
50
|
+
"april_dates": 4,
|
51
|
+
"june_dates": 6,
|
52
|
+
"july_dates": 7,
|
53
|
+
"august_dates": 8,
|
54
|
+
"september_dates": 9,
|
55
|
+
"october_dates": 10,
|
56
|
+
"november_dates": 11,
|
57
|
+
"december_dates": 12,
|
58
|
+
}
|
59
|
+
return map[value]
|
60
|
+
}
|
61
|
+
|
33
62
|
function getTime(time) {
|
34
63
|
let hour = 0
|
35
64
|
const minute = 0
|
@@ -57,7 +86,31 @@ function getTime(time) {
|
|
57
86
|
}
|
58
87
|
|
59
88
|
instantiate = (isA, now, context) => {
|
60
|
-
|
89
|
+
const getType = (context, type) => {
|
90
|
+
if (context.marker == 'onDate_dates' && context.date?.marker == type) {
|
91
|
+
return context.date
|
92
|
+
} if (context.marker == type) {
|
93
|
+
return context
|
94
|
+
}
|
95
|
+
}
|
96
|
+
let value
|
97
|
+
if (value = getType(context, 'monthDay_dates')) {
|
98
|
+
const day = value.day.value;
|
99
|
+
const month = toMonthNumber(value.month.value);
|
100
|
+
debugger
|
101
|
+
const currentMonth = now.getMonth() + 1; // 1-based (January = 1)
|
102
|
+
const currentYear = now.getFullYear();
|
103
|
+
const year = currentMonth >= month ? currentYear + 1 : currentYear;
|
104
|
+
|
105
|
+
const date = new Date(year, month-1, day)
|
106
|
+
return date.toISOString()
|
107
|
+
} else if (value = getType(context, 'monthDayYear_dates')) {
|
108
|
+
const day = value.day.value;
|
109
|
+
const month = toMonthNumber(value.month.value);
|
110
|
+
const year = value.year.value;
|
111
|
+
const date = new Date(year, month-1, day)
|
112
|
+
return date.toISOString()
|
113
|
+
} else if (isA(context?.marker, 'dateTimeSelector')) {
|
61
114
|
// (on date) OR (date)
|
62
115
|
const date = context.date?.date || context.date
|
63
116
|
const dateTimeSelector = getNextDayOfWeek(now, date.value)
|