Enhance PersonEdit form: Add birthdate input with validation, improve field error handling using hasValidationError, refactor birthDate to respect timezone offsets, and update translations for better user feedback. Replace DateTimeCreate with DateTimeWrite across types and components.

This commit is contained in:
2025-09-18 11:32:36 +02:00
parent 54f8c92240
commit bbd4292cb9
6 changed files with 80 additions and 14 deletions

View File

@@ -158,3 +158,18 @@ export const intervalISOToDays = (str: string | null): number | null => {
return days;
};
export function getTimezoneOffsetString(date: Date, timeZone: string): string {
const utcDate = new Date(date.toLocaleString("en-US", { timeZone: "UTC" }));
const tzDate = new Date(date.toLocaleString("en-US", { timeZone }));
const offsetMinutes = (utcDate.getTime() - tzDate.getTime()) / (60 * 1000);
// Inverser le signe pour avoir la convention ±HH:MM
const sign = offsetMinutes <= 0 ? "+" : "-";
const absMinutes = Math.abs(offsetMinutes);
const hours = String(Math.floor(absMinutes / 60)).padStart(2, "0");
const minutes = String(absMinutes % 60).padStart(2, "0");
return `${sign}${hours}:${minutes}`;
}

View File

@@ -8,9 +8,9 @@ export interface DateTime {
}
/**
* A date representation to use when we create an instance
* A date representation to use when we create or update a date
*/
export interface DateTimeCreate {
export interface DateTimeWrite {
/**
* Must be a string in format Y-m-d\TH:i:sO
*/