style: enhance layout and functionality of duty markers and calendar
- Updated CSS for `.day` and `.access-denied` to improve layout and visual consistency. - Introduced a new function `dutyOverlapsLocalRange` in `dateUtils.js` to check duty overlaps within a specified date range. - Refactored `dutyItemHtml` in `dutyList.js` to utilize `formatTimeLocal` for time formatting, enhancing readability. - Added utility functions in `hints.js` for parsing duty marker data and building time prefixes, streamlining hint rendering logic. - Improved the `showAccessDenied` function in `ui.js` to display detailed server messages when access is denied.
This commit is contained in:
@@ -29,6 +29,23 @@ export function dutyOverlapsLocalDay(d, dateKey) {
|
||||
return end > dayStart && start < dayEnd;
|
||||
}
|
||||
|
||||
/**
|
||||
* True if duty overlaps any local day in the range [firstKey, lastKey] (inclusive).
|
||||
* @param {object} d - Duty with start_at, end_at
|
||||
* @param {string} firstKey - YYYY-MM-DD (first day of range)
|
||||
* @param {string} lastKey - YYYY-MM-DD (last day of range)
|
||||
* @returns {boolean}
|
||||
*/
|
||||
export function dutyOverlapsLocalRange(d, firstKey, lastKey) {
|
||||
const [y1, m1, day1] = firstKey.split("-").map(Number);
|
||||
const [y2, m2, day2] = lastKey.split("-").map(Number);
|
||||
const rangeStart = new Date(y1, m1 - 1, day1, 0, 0, 0, 0);
|
||||
const rangeEnd = new Date(y2, m2 - 1, day2, 23, 59, 59, 999);
|
||||
const start = new Date(d.start_at);
|
||||
const end = new Date(d.end_at);
|
||||
return end > rangeStart && start < rangeEnd;
|
||||
}
|
||||
|
||||
/** @param {Date} d - Date */
|
||||
export function firstDayOfMonth(d) {
|
||||
return new Date(d.getFullYear(), d.getMonth(), 1);
|
||||
|
||||
Reference in New Issue
Block a user