1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-05 22:27:34 +02:00

fix for date field without click on calendar

This commit is contained in:
Jimako
2025-02-09 13:02:47 +01:00
committed by Nick Liu
parent 6f8d4478be
commit 873966c5ce

View File

@@ -24,7 +24,32 @@ var e107 = e107 || {'settings': {}, 'behaviors': {}};
var newTarget = "#" + id.replace("e-datepicker-", "");
$(newTarget).val(newValue);
}
// If UNIX timestamp is required, manually convert the date string (dd.mm.yyyy)
if (useUnix === "true") {
var parts = newValue.split(".");
if (parts.length === 3) {
var day = parseInt(parts[0], 10);
var month = parseInt(parts[1], 10) - 1; // Month is zero-based in JS
var year = parseInt(parts[2], 10);
// Validate date parts
if (!isNaN(day) && !isNaN(month) && !isNaN(year)) {
var date = new Date(year, month, day);
var unixTimestamp = Math.floor(date.getTime() / 1000);
var id = $this.attr("id");
var newTarget = "#" + id.replace("e-datepicker-", "");
$(newTarget).val(unixTimestamp); // Update hidden UNIX field
}
}
} else {
// If not using UNIX timestamp, update with raw value
var id = $this.attr("id");
var newTarget = "#" + id.replace("e-datepicker-", "");
$(newTarget).val(newValue); // Update hidden field with text input value
}
});
});
$(context).find('input.e-date').once('datetimepicker-init').each(function () {