mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-10-01 02:49:42 +00:00
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:
@@ -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}`;
|
||||
}
|
||||
|
||||
|
@@ -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
|
||||
*/
|
||||
|
Reference in New Issue
Block a user