对输入的日期进行快捷增加或减少日期
// 参数:1、 时间实例化后;2、相差几月;3、时间类型// timeType: 1、 日:Date,月:Month,年:FullYearfunction timeDiff(date, offset, timeType) {if(!(date instanceof Date)) {throw Error('第一参数为实例化后的时间');}if(!(parseInt(offset) >= 0) && !(parseInt(offset) < 0)) {throw Error('第二参数为正整数或负整数或零');}if(timeType !== "Date" && timeType !== "Month" && timeType !== "FullYear") {throw Error('第三参数:日:Date,月:Month,年:FullYear');}var getTime = "get" + timeType;var setTime = "set" + timeType;var time = date[getTime]();var diff = time + offset;date[setTime](diff);return date;}
