import moment from "moment-timezone";

export const convertUTCToLocalTime = (value: any, customFormat: any) => {
    // UTC timestamp
    const utcTimestamp = value?.date_time_utc;
    let targetTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone
    const localTime = moment.utc(utcTimestamp).tz(targetTimeZone);

    // Format the local time
    const formattedLocalDate = customFormat ? localTime.format('DD MMMM YYYY') : localTime.format('YYYY-MM-DD');
    const formattedLocalTime = localTime.format('h:mm A');
    
    return { date: formattedLocalDate, time: formattedLocalTime }
}