components_node/functions-generic.js
/**
     * Function to return formatted date.
     * @static
     * @param {string} strDate 14/01/2016 |  01/14/2016
     * @param {integer} configDateFormat 1 - PT | 2 - UK | configBackendDateFormat | configFrontendDateFormat
     * @param {integer} dateFormatReturn 0 - deactivated (automatic from dateType) | 1 - (dd/mm/yyyy | mm/dd/yyyy) | 2 - (dd/mm/yyyy hh:mm:ss | mm/dd/yyyy hh:mm:ss) | 3 - yyyy-mm-dd hh:mm:ss | 10 - (yyyy-mm-dd) | 11 - yyyy-mm-ddThh:mm:ss | 22 - hh:mm:ss | 101 - written date (weekday, month day year)
     * @param {integer} dateType null - deactivated | 1 - simple date (year, month, day) | 2 -  complete date (year, month, day, hour, minute, seconds) | 3 - semi-complete date (year, month, day, hour, minute) | 4 - birth date (limited range) | 5 - task date (forward on) | 6 - history date (backwards on)  | 55 - task date with hour and minute (forward on) | 66 - history date with hour and minute (backwards on)
     * @returns {string} 
     */
Function to return formatted date.
Function to return formatted date .
static dateRead01(strDate, configDateFormat, dateFormatReturn, dateType = null)
    {
        let strReturn = "";
        let dateObj;
        let dateYear, dateDay, dateMonth, dateHour, dateMinute, dateSecond;
        if(strDate)
        {
            dateObj = new Date(strDate);
            dateYear = dateObj.getFullYear();
            dateDay = dateObj.getDate();
            dateMonth = (dateObj.getMonth() + 1);
            dateHour = ("0" + dateObj.getHours()).slice(-2);
            dateMinute = ("0" + dateObj.getMinutes()).slice(-2);
            dateSecond = ("0" + dateObj.getSeconds()).slice(-2);
            if(dateType)
            {
                if(dateType == 1 || dateType == 4)
                {
                    dateFormatReturn = 1;
                }else{
                    dateFormatReturn = 2;
                }
            }
            if(dateFormatReturn == 1)
            {
                if(configDateFormat == 1)
                {
                    strReturn = dateDay + "/" + dateMonth + "/" + dateYear;
                }
                if(configDateFormat == 2)
                {
                    strReturn =  dateMonth + "/" + dateDay + "/" + dateYear;
                }
            }
            if(dateFormatReturn == 2)
            {
                if(configDateFormat == 1)
                {
                    strReturn = dateDay + "/" + dateMonth + "/" + dateYear + " " + dateHour + ":" + dateMinute + ":" + dateSecond;
                }
                if(configDateFormat == 2)
                {
                    strReturn =  dateMonth + "/" + dateDay + "/" + dateYear + " " + dateHour + ":" + dateMinute + ":" + dateSecond;
                }
            }
            if(dateFormatReturn == 3)
            {
                strReturn = dateYear + "-" + dateMonth + "-" + dateDay + " " + dateHour + ":" + dateMinute + ":" + dateSecond;
            }
        }
        return strReturn;
    }
static dateRead01 ( strDate , configDateFormat , dateFormatReturn , dateType = null ) { let strReturn = "" ; let dateObj ; let dateYear , dateDay , dateMonth , dateHour , dateMinute , dateSecond ; if ( strDate ) { dateObj = new Date ( strDate ) ; dateYear = dateObj . getFullYear ( ) ; dateDay = dateObj . getDate ( ) ; dateMonth = ( dateObj . getMonth ( ) + 1 ) ; dateHour = ( "0" + dateObj . getHours ( ) ) . slice ( - 2 ) ; dateMinute = ( "0" + dateObj . getMinutes ( ) ) . slice ( - 2 ) ; dateSecond = ( "0" + dateObj . getSeconds ( ) ) . slice ( - 2 ) ; if ( dateType ) { if ( dateType == 1 || dateType == 4 ) { dateFormatReturn = 1 ; } else { dateFormatReturn = 2 ; } } if ( dateFormatReturn == 1 ) { if ( configDateFormat == 1 ) { strReturn = dateDay + "/" + dateMonth + "/" + dateYear ; } if ( configDateFormat == 2 ) { strReturn = dateMonth + "/" + dateDay + "/" + dateYear ; } } if ( dateFormatReturn == 2 ) { if ( configDateFormat == 1 ) { strReturn = dateDay + "/" + dateMonth + "/" + dateYear + " " + dateHour + ":" + dateMinute + ":" + dateSecond ; } if ( configDateFormat == 2 ) { strReturn = dateMonth + "/" + dateDay + "/" + dateYear + " " + dateHour + ":" + dateMinute + ":" + dateSecond ; } } if ( dateFormatReturn == 3 ) { strReturn = dateYear + "-" + dateMonth + "-" + dateDay + " " + dateHour + ":" + dateMinute + ":" + dateSecond ; } } return strReturn ; }
Function to return formatted date.
Function to return formatted date .
//configDateFormat: 1 - pt | 2 uk | configBackendDateFormat | configFrontendDateFormat //dateFormatReturn: 0 - deactivated (automatic from dateType) | 1 - (dd/mm/yyyy | mm/dd/yyyy) | 2 - (dd/mm/yyyy hh:mm:ss | mm/dd/yyyy hh:mm:ss) | 3 - yyyy-mm-dd hh:mm:ss | 10 - (yyyy-mm-dd) | 11 - yyyy-mm-ddThh:mm:ss | 22 - hh:mm:ss | 101 - written date (weekday, month day year) //dateType: null - deactivated | 1 - simple date (year, month, day) | 2 -  complete date (year, month, day, hour, minute, seconds) | 3 - semi-complete date (year, month, day, hour, minute) | 4 - birth date (limited range) | 5 - task date (forward on) | 6 - history date (backwards on)  | 55 - task date with hour and minute (forward on) | 66 - history date with hour and minute (backwards on) //Variables. //---------------------- //let dateObj = new Date(); //---------------------- //Variable value. //dateObj = strDate; //worked with node, but didn´t work with react //dateHour = dateObj.getHours(); //dateMinute = dateObj.getMinutes(); //dateSecond = dateObj.getSeconds(); //Automatic define dateFormatReturn. //1 - (dd/mm/yyyy | mm/dd/yyyy) //1 - pt //2 uk //2 - (dd/mm/yyyy hh:mm:ss | mm/dd/yyyy hh:mm:ss) //1 - pt //2 uk //3 - yyyy-mm-dd hh:mm:ss //Usage. //---------------------- /*
        SyncSystemNS.FunctionsGeneric.dateRead01(categoriesRow.date1, 
                                                gSystemConfig.configBackendDateFormat, 
                                                0, 
                                                gSystemConfig.configCategoriesDate1Type);
        */ //----------------------