- Enhance RequestPermitModal with multiple time-off types and validation - Implement CalendarWidget for visualizing time-off requests - Improve API error handling and token management - Add utility functions for consistent date and time formatting - Clean up unused mock data and update types
22 lines
696 B
TypeScript
22 lines
696 B
TypeScript
/**
|
|
* Trasforma una data da "YYYY-MM-DD" a "DD/MM/YYYY"
|
|
* @param dateStr stringa data in formato ISO "YYYY-MM-DD"
|
|
* @returns stringa formattata "DD/MM/YYYY"
|
|
*/
|
|
export const formatDate = (dateStr: string | null | undefined): string => {
|
|
if (!dateStr) return '';
|
|
const [year, month, day] = dateStr.split('-');
|
|
return `${day}/${month}/${year}`;
|
|
};
|
|
|
|
/**
|
|
* Trasforma un'ora da "HH:MM:SS" a "HH:MM"
|
|
* @param timeStr stringa ora in formato "HH:MM:SS"
|
|
* @returns stringa formattata "HH:MM"
|
|
*/
|
|
export const formatTime = (timeStr: string | null | undefined): string => {
|
|
if (!timeStr) return '';
|
|
const [hours, minutes] = timeStr.split(':');
|
|
return `${hours}:${minutes}`;
|
|
};
|