finished schedule module

This commit is contained in:
faris Aljohari
2024-09-15 18:03:30 +03:00
parent 0df4af175f
commit d962d4a7b3
11 changed files with 559 additions and 0 deletions
@@ -0,0 +1,23 @@
export function convertTimestampToDubaiTime(timestamp) {
// Convert timestamp to milliseconds
const date = new Date(timestamp * 1000);
// Convert to Dubai time (UTC+4)
const dubaiTimeOffset = 4 * 60; // 4 hours in minutes
const dubaiTime = new Date(date.getTime() + dubaiTimeOffset * 60 * 1000);
// Format the date as YYYYMMDD
const year = dubaiTime.getUTCFullYear();
const month = String(dubaiTime.getUTCMonth() + 1).padStart(2, '0'); // Months are zero-based
const day = String(dubaiTime.getUTCDate()).padStart(2, '0');
// Format the time as HH:MM (24-hour format)
const hours = String(dubaiTime.getUTCHours()).padStart(2, '0');
const minutes = String(dubaiTime.getUTCMinutes()).padStart(2, '0');
// Return formatted date and time
return {
date: `${year}${month}${day}`,
time: `${hours}:${minutes}`,
};
}