/**
 * @since Last modified: 2024/05/06 00:19:13
 * @function getUTCTimestamp
 * @description Convert local date or timestamp to UTC timestamp.
 * @param {string|number|Date} value  - The date string or timestamp.
 * @returns {HTMLElement|null} Return a number of UTC timestamp.
 * @see {@link https://codepen.io/axui/pen/QWPevdd|demo @ codepen}
 * @example
 * ax.getUTCTimestamp(1715009409475);
 * <!--return the utc timestamp-->
 */



'use strict';
import { T_el } from '../../../types/ax';
import config from '../global/config';
import getDataType from './getDataType';
import getEl from './getEl';
import isDateStr from './isDateStr';
import isEmpty from './isEmpty';
import trim from './trim';

const getUTCTimestamp = (value: number | string | Date): number => {
    let date: any,
        offset: number,
        dateTamp: number,
        valType = getDataType(value);
    if (valType === 'Date') {
        
        date = value;
    } else if (valType === 'String') {
        if (isDateStr(value as string)) {
            date = new Date(value);
        } else {
            date = new Date();
        }
    } else if (valType === 'Number') {
        
        date = new Date(value);
    } else {
        
        date = new Date();
    }
    dateTamp = date.getTime();
    offset = date.getTimezoneOffset() * 60000;
    return dateTamp + offset;
}
export default getUTCTimestamp;
