@iapps/ng-dhis2-ui 1.2.154 → 1.2.155
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/fesm2022/iapps-ng-dhis2-ui.mjs +38 -19
- package/fesm2022/iapps-ng-dhis2-ui.mjs.map +1 -1
- package/index.d.ts +13 -12
- package/package.json +1 -1
|
@@ -9169,18 +9169,18 @@ class BaseFormFieldComponent extends ReactWrapperModule {
|
|
|
9169
9169
|
`${pad(date.getMinutes())}`);
|
|
9170
9170
|
}
|
|
9171
9171
|
/**
|
|
9172
|
-
|
|
9173
|
-
|
|
9174
|
-
|
|
9175
|
-
|
|
9176
|
-
|
|
9177
|
-
|
|
9178
|
-
|
|
9179
|
-
|
|
9180
|
-
|
|
9181
|
-
|
|
9182
|
-
|
|
9183
|
-
|
|
9172
|
+
* Normalizes value from the HTML input into DHIS storage format.
|
|
9173
|
+
*
|
|
9174
|
+
* For date:
|
|
9175
|
+
* - Input: "YYYY-MM-DD"
|
|
9176
|
+
* - Output: "YYYY-MM-DD"
|
|
9177
|
+
*
|
|
9178
|
+
* For datetime:
|
|
9179
|
+
* - Input: "YYYY-MM-DDTHH:mm" (local)
|
|
9180
|
+
* - Output: ISO string in UTC: "YYYY-MM-DDTHH:mm:ss.sssZ"
|
|
9181
|
+
*
|
|
9182
|
+
* If allowFutureDate = false, any value beyond "now" is clamped to now.
|
|
9183
|
+
*/
|
|
9184
9184
|
normalizeDateValueFromHtmlInput(inputValue, isDateTimeField, allowFutureDate) {
|
|
9185
9185
|
const trimmed = (inputValue ?? '').trim();
|
|
9186
9186
|
if (!trimmed)
|
|
@@ -9202,19 +9202,38 @@ class BaseFormFieldComponent extends ReactWrapperModule {
|
|
|
9202
9202
|
if (!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}$/.test(trimmed)) {
|
|
9203
9203
|
return null;
|
|
9204
9204
|
}
|
|
9205
|
-
// Interpret as
|
|
9206
|
-
const
|
|
9207
|
-
|
|
9205
|
+
// Interpret selected datetime as EAT, not UTC/GMT
|
|
9206
|
+
const eatDateTimeValue = `${trimmed}:00.000+03:00`;
|
|
9207
|
+
const eatDate = new Date(eatDateTimeValue);
|
|
9208
|
+
if (Number.isNaN(eatDate.getTime())) {
|
|
9208
9209
|
return null;
|
|
9209
9210
|
}
|
|
9210
9211
|
if (!allowFutureDate) {
|
|
9211
9212
|
const now = new Date();
|
|
9212
|
-
if (
|
|
9213
|
-
return
|
|
9213
|
+
if (eatDate.getTime() > now.getTime()) {
|
|
9214
|
+
return this.getNowInEatIsoString();
|
|
9214
9215
|
}
|
|
9215
9216
|
}
|
|
9216
|
-
|
|
9217
|
-
|
|
9217
|
+
return eatDateTimeValue;
|
|
9218
|
+
}
|
|
9219
|
+
getNowInEatIsoString() {
|
|
9220
|
+
const formatter = new Intl.DateTimeFormat('en-GB', {
|
|
9221
|
+
timeZone: 'Africa/Dar_es_Salaam',
|
|
9222
|
+
year: 'numeric',
|
|
9223
|
+
month: '2-digit',
|
|
9224
|
+
day: '2-digit',
|
|
9225
|
+
hour: '2-digit',
|
|
9226
|
+
minute: '2-digit',
|
|
9227
|
+
second: '2-digit',
|
|
9228
|
+
hourCycle: 'h23',
|
|
9229
|
+
});
|
|
9230
|
+
const parts = formatter.formatToParts(new Date()).reduce((acc, part) => {
|
|
9231
|
+
if (part.type !== 'literal') {
|
|
9232
|
+
acc[part.type] = part.value;
|
|
9233
|
+
}
|
|
9234
|
+
return acc;
|
|
9235
|
+
}, {});
|
|
9236
|
+
return `${parts['year']}-${parts['month']}-${parts['day']}T${parts['hour']}:${parts['minute']}:${parts['second']}.000+03:00`;
|
|
9218
9237
|
}
|
|
9219
9238
|
async searchForDuplicates(value) {
|
|
9220
9239
|
const d2 = window.d2Web;
|