Files
Meeting-Mixer/js/utils.js
T
ferdi2goandClaude Opus 4.8 836d0eeda5 chore: unify name to "Meeting Mixer", README tech stack, name magic numbers (#16)
- Canonical name "Meeting Mixer" everywhere: <title>, README, .vch-description
  (now non-technical per convention) and package.json (meeting-mixer).
- README gains a Tech-Stack section and an accurate, non-misleading port note.
- Magic numbers replaced by named constants: LOW_PRIORITY_PENALTY in
  algorithm.js; MIN/MAX_MODERATORS_PER_DAY in utils.js, used by data.js,
  calendar.js and app.js.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-03 13:44:45 +00:00

34 lines
1.0 KiB
JavaScript

// Shared pure helpers and constants used across modules.
// Allowed range for the "moderators per day" setting.
export const MIN_MODERATORS_PER_DAY = 1;
export const MAX_MODERATORS_PER_DAY = 5;
// "YYYY-MM-DD" from numeric parts.
export function toISO(year, month, day) {
return year + '-' + String(month).padStart(2, '0') + '-' + String(day).padStart(2, '0');
}
// "YYYY-MM" month prefix (used to filter history by month).
export function monthPrefix(year, month) {
return year + '-' + String(month).padStart(2, '0');
}
// Weekday for an ISO date string: 1=Mo, 2=Di, 3=Mi, 4=Do, 5=Fr, 6=Sa, 7=So.
export function getWeekday(isoDate) {
const d = new Date(isoDate + 'T12:00:00Z').getUTCDay(); // 0=Sun
return d === 0 ? 7 : d;
}
// "DD.MM.YYYY" from an ISO date string.
export function formatDateDE(isoDate) {
const [y, m, d] = isoDate.split('-');
return d + '.' + m + '.' + y;
}
// { [id]: name } lookup map from an employees array.
export function buildNameMap(employees) {
return Object.fromEntries(employees.map(e => [e.id, e.name]));
}