@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.
@@ -9169,18 +9169,18 @@ class BaseFormFieldComponent extends ReactWrapperModule {
9169
9169
  `${pad(date.getMinutes())}`);
9170
9170
  }
9171
9171
  /**
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
- */
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 LOCAL time
9206
- const localDate = new Date(trimmed);
9207
- if (Number.isNaN(localDate.getTime())) {
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 (localDate.getTime() > now.getTime()) {
9213
- return now.toISOString();
9213
+ if (eatDate.getTime() > now.getTime()) {
9214
+ return this.getNowInEatIsoString();
9214
9215
  }
9215
9216
  }
9216
- // Store as UTC ISO string with millis, e.g. "2025-11-26T21:01:00.000Z"
9217
- return localDate.toISOString();
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;