// 取得當月1號 function getMonthFirstDay() { var firstday = new Date(); firstday.setDate(1); return (firstday.toFormat("yyyymmdd")); } // 取得當月最後一天 function getMonthLastDay() { var lastday = new Date(); lastday.setDate(1); lastday = lastday.DateAdd("m", 1); lastday = lastday.DateAdd("d", -1); return (lastday.toFormat("yyyymmdd")); } // 取得起時到迄時之時間(分鐘數) // 傳入為分鐘數, 如 08:30 傳入 510 (8*60+30) function getTimeRange(time_from, time_to) { if (time_from === "" || time_to === "") return ""; if (time_from >= 1440) time_from = time_from % 1440; if (time_to >= 1440) time_to = time_to % 1440; if (time_to < time_from) // 跨夜 ex: 21:00~03:00 { return (1440 - time_from) + time_to; } else { return time_to - time_from; } } // 檢查休息時段(off_from, off_to)是否在班表時段(time_from, time_to) function isInTimeRange(time_from, time_to, off_from, off_to) { if (time_from === "" || time_to === "") return false; if (off_from === "" || off_to === "") return false; // if (time_to < time_from) // 跨夜 ex: 21:00~03:00 { if (off_from < time_from && off_from > time_to) return false; if (off_to < time_from && off_to > time_to) return false; return true; } else { if (off_from < time_from || off_from > time_to) return false; if (off_to < time_from || off_to > time_to) return false; return true; } } // 輸入分鐘數, 取得 X時Y分 function getChineseHHMM(mm) { return parseInt((mm / 60)) + "時" + (mm % 60) + "分"; }