class DateUtils {

    //--------------------------
    // constructor
    //--------------------------
    constructor() {}

    //--------------------------
    // methods
    //--------------------------
    getMKtime() {
        var time = new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate(), new Date().getHours(), new Date().getMinutes(), new Date().getSeconds(), 0).getTime() / 1000;
        return time;
    }

    convertMKtime(seconds) {
        var date = new Date(seconds * 1000);
        return date;
    }

    getDate(type, rawdate) { 
        var day = ((rawdate != null || rawdate != '') ? String(new Date(rawdate).getUTCDate()) : String(new Date().getUTCDate()));
        var month = ((rawdate != null || rawdate != '') ? String(new Date(rawdate).getUTCMonth()+1) : String(new Date().getUTCMonth()+1));
        var year = ((rawdate != null || rawdate != '') ? String(new Date(rawdate).getUTCFullYear()) : String(new Date().getUTCFullYear()));
        var hour = ((rawdate != null || rawdate != '') ? String(new Date(rawdate).getUTCHours()) : String(new Date().getUTCHours()));
        var minute = ((rawdate != null || rawdate != '') ? String(new Date(rawdate).getUTCMinutes()) : String(new Date().getUTCMinutes()));
        var seconds = ((rawdate != null || rawdate != '') ? String(new Date(rawdate).getUTCSeconds()) : String(new Date().getUTCSeconds()));
        var millisecond = ((rawdate != null || rawdate != '') ? String(new Date(rawdate).getUTCMilliseconds()) : String(new Date().getUTCMilliseconds()));
        if (day.length == 1)
            day = String("0" + day);
        if (month.length == 1)
            month = String("0" + month);
        switch (type) {
            case "day":
                return day;
                break;
            case "month":
                return month;
                break;
            case "year":
                return year;
                break;
            case "stamp":
                return String(year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + seconds+"."+millisecond);
                break
            default:
                return String(year + "-" + month + "-" + day + " : " + hour + "-" + minute + "-" + seconds);
                break;
        }
    }

    //--------------------------
    // event handlers
    //--------------------------
}

export default DateUtils