export const Decorator = {
    ChangeServerDateTimeToISODateTime: (date) => {
        if (!date) {
            return '';
        }
        var newData = date.substr(0, 19);
        return newData.replace('T', ' ');
    },
    ChangeISODateTimeToServerDateTime: (date) => {
        if (!date) {
            return null;
        }
        return date.replace(' ', 'T');
    },
    ChangeISODateTimeToDate: (date) => {
        if (!date) {
            return null;
        }
        var newData = date.substr(0, 10);
        return newData;
    },
    ChangeISODateTimeToDateYYMM: (date) => {
        if (!date) {
            return null;
        }
        var newData = date.substr(0, 7);
        return newData;
    },
    ChangeISODateTimeToMMdd: (date) => {
        if (!date) {
            return null;
        }
        var newDate = new Date(date.substr(0, 4), parseInt(date.substr(5, 2)) - 1, date.substr(8, 2));
        return newDate.getMonth() + 1 + "/" + newDate.getDate();
    },
    ChangeISODateTimeToYYMMdd: (date) => {
        if (!date) {
            return null;
        }
        var newDate = new Date(date.substr(0, 4), parseInt(date.substr(5, 2)) - 1, date.substr(8, 2));
        return newDate.getFullYear().toString().slice(-2) + "/" + (newDate.getMonth() + 1) + "/" + newDate.getDate();
    },
    ChangeStringToDate: (str) => {
        if (!str) {
            return null;
        }
        var newDate = new Date(str.substr(0, 4), parseInt(str.substr(5, 2)) - 1, str.substr(8, 2));
        return newDate;
    },
    ChangeISODateTimeToTwDate: (date) => {
        if (!date) {
            return null;
        }
        var str = date.substr(0, 10);

        return parseInt(str.substr(0, 4) - 1911) + " 年 " + str.substr(5, 2) + " 月 " + str.substr(8, 2) + " 日";
    }
}