{"size": 992, "ext": "js", "max_stars_repo_path": "front-vue/dash-board/src/util/DateUtil.js", "max_stars_repo_name": "KimUihyeon/dash_board_web", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "front-vue/dash-board/src/util/DateUtil.js", "max_issues_repo_name": "KimUihyeon/dash_board_web", "max_issues_repo_issues_event_min_datetime": "2020-05-27T16:42:11.000Z", "max_issues_repo_issues_event_max_datetime": "2020-10-06T12:53:04.000Z", "max_forks_repo_path": "front-vue/dash-board/src/util/DateUtil.js", "max_forks_repo_name": "KimUihyeon/dash_board_web", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 6, "max_forks_count": null, "avg_line_length": 17.7142857143, "max_line_length": 63, "alphanum_fraction": 0.5977822581}
const moment = require('moment');

/**
 * 
 * @param {String} type 
 * @param {number} dateTime 
 */

const formatting = (moment ,format) =>{

    if(format === null || format === undefined ){
        format = 'YYYY-MM-DD HH:mm:ss';
    }
    
    return  moment.format(format)
}



export const now = (format) => {
    return formatting(moment(moment.now()) , format);
}


export const convertByUnixDateTime = (unix_DateTime,format) =>{
    var date = new Date(unix_DateTime * 1000);
    return formatting(moment(date) , format);
}


export const format = (dateStr, format) =>{
    return moment(dateStr).format(format);
}


export const addDays = (date, addDays, format) => {
    let _f = format;
    if(_f === undefined || f === null){
        _f = "YYYY-MM-DD"
    }

    return moment(date, _f).add(addDays, 'days').format(_f);
}



export const date = {
    now,
    convertByUnixDate : (dateTime) => {
        return convertByUnixDateTime(dateTime);
    },
    format,
    addDays,

}
