waffles: calendar: generalize first day of week

This commit is contained in:
end-4
2025-11-27 13:17:24 +01:00
parent d40df98aa5
commit 0700e024d9
5 changed files with 26 additions and 31 deletions
@@ -8,14 +8,14 @@ RowLayout {
id: root
// Pls supply
required property date date
property bool sundayFirst: false
required property date date // Any date within the week
property var locale
// Expose model and delegate for flexibility
property list<var> model: {
// Should expose props like here: https://doc.qt.io/qt-6/qml-qtquick-controls-monthgrid.html#delegate-prop
// (except weekNumber because i'm lazy and it's not so important)
const firstDayOfWeek = DateUtils.getMonday(root.date, root.sundayFirst);
const firstDayOfWeek = DateUtils.getFirstDayOfWeek(root.date, root.locale.firstDayOfWeek);
const weekDates = [];
for (let i = 0; i < 7; i++) {
const dayDate = new Date(firstDayOfWeek);