I've been working with a calendar data that is sent to the server, which includes the following fields:
export interface CalendarDate{
dayOfMonth: number;
hourOfDay: number;
minute: number;
month: number;
second: number;
year: number;
}
My goal is to convert this data into a JavaScript Date while taking into account the time offset calculation. After reading multiple articles on this topic, I came up with the following solution. Would this method be effective under all circumstances?
return new Date(modificationDate.year, modificationDate.month, modificationDate.dayOfMonth,
modificationDate.hourOfDay, modificationDate.minute -new Date().getTimezoneOffset(), modificationDate.second);