export default {
    methods: {
        CNDateString(date) {
            var cn = ["〇", "一", "二", "三", "四", "五", "六", "七", "八", "九"];
            var s = [];
            var YY = date.getFullYear().toString();
            for (var i = 0; i < YY.length; i++)
                if (cn[YY.charAt(i)])
                    s.push(cn[YY.charAt(i)]);
                else
                    s.push(YY.charAt(i));
            s.push("年");
            var MM = date.getMonth() + 1;
            if (MM < 10)
                s.push(cn[MM]);
            else if (MM < 20)
                s.push("十" + cn[MM % 10]);
            s.push("月");
            var DD = date.getDate();
            if (DD < 10)
                s.push(cn[DD]);
            else if (DD < 20)
                s.push("十" + cn[DD % 10]);
            else
                s.push("二十" + cn[DD % 10]);
            s.push("日");
            return s.join('');
        },
        converToDate(date) {
            var chinese = ['〇', '一', '二', '三', '四', '五', '六', '七', '八', '九'];
            var y = date.getFullYear().toString();
            var m = date.getMonth().toString();
            var d = date.getDate().toString();
            var result = "";
            for (var i = 0; i < y.length; i++) {
                result += chinese[y.charAt(i)];
            }
            result += "年";
            if (m.length == 2) {
                if (m.charAt(0) == "1") {
                    result += ("十" + chinese[m.charAt(1)] + "月");
                }
            } else {
                result += (chinese[m.charAt(0)] + "月");
            }
            if (d.length == 2) {
                if (d.charAt(0) == "1") {
                    result += ("十" + chinese[d.charAt(1)] + "日");
                }else if (d.charAt(0) == "2") {
                    result += ("二十" + chinese[d.charAt(1)] + "日");
                }if (d.charAt(0) == "3") {
                    result += ("三十" + chinese[d.charAt(1)] + "日");
                }
            } else {
                result += (chinese[d.charAt(0)] + "日");
            }
            return result;
        }
    }
}
