added feature to pick monday/sunday as first-day-of-week
authorPhiTux <redacted>
Wed, 22 Oct 2025 14:09:32 +0000 (16:09 +0200)
committerPhiTux <redacted>
Wed, 22 Oct 2025 14:09:32 +0000 (16:09 +0200)
README.md
backend/handlers/settings.go
frontend/src/lib/Datepicker.svelte
frontend/src/routes/(authed)/+layout.svelte

index fa65a707b838a9b5e5b59c821ad1c1f088cae120..11dba07a53286d48cc0a56d88c7c65837279d54e 100644 (file)
--- a/README.md
+++ b/README.md
@@ -166,6 +166,10 @@ The old version 1 is moved to the [v1 branch](https://github.com/PhiTux/DailyTxT
 
 ### Newest Testing Versions:
 ```
+2.0.0-testing.4 (2025-10-22)
+- Fixed a bug, that showed wrong weekdays in the calendar
+- Added a feature to choose the first day of the week (Monday or Sunday) in the settings.
+
 2.0.0-testing.3 (2025-10-13)
 - Updated the migration process in the frontend. When migration fails on serverside, the user now gets notified.
 
index 6aa3ebea376c66a64801b9d77890fea09248a094..f1e3ad0bfe5bd310356046c35ab9c434146301b0 100644 (file)
@@ -27,6 +27,7 @@ func GetDefaultSettings() map[string]any {
                "checkForUpdates":            true,
                "includeTestVersions":        false,
                "requirePasswordOnPageLoad":  false,
+               "firstDayOfWeek":             "monday",
        }
 }
 
index 9403948666a89c371cecba33a08cb45620100a97..eac204e92c00b82153448b1e1a18347bf16481b4 100644 (file)
@@ -1,6 +1,6 @@
 <script>
        import { cal, selectedDate, readingDate } from '$lib/calendarStore.js';
-       import { readingMode } from '$lib/settingsStore.js';
+       import { readingMode, settings } from '$lib/settingsStore.js';
        import { onMount } from 'svelte';
        import { fly } from 'svelte/transition';
        import * as bootstrap from 'bootstrap';
                const lastDay = new Date(year, month + 1, 0);
 
                let tempDays = [];
-               // monday is first day
-               let firstDayIndex = firstDay.getDay() - 1;
-               if (firstDayIndex === -1) firstDayIndex = 6; // sunday gets 6
+               let firstDayIndex;
+
+               if ($settings.firstDayOfWeek === 'sunday') {
+                       // sunday is first day
+                       firstDayIndex = firstDay.getDay();
+               } else {
+                       // monday is first day
+                       firstDayIndex = firstDay.getDay() - 1;
+                       if (firstDayIndex === -1) firstDayIndex = 6; // sunday gets 6
+               }
 
                for (let i = 0; i < firstDayIndex; i++) {
                        tempDays.push(null); // Fill empty slots before the first day
                }
        };
 
-       // weekdays
-       const weekDays = [
-               $t('calendar.day_short.monday'),
-               $t('calendar.day_short.tuesday'),
-               $t('calendar.day_short.wednesday'),
-               $t('calendar.day_short.thursday'),
-               $t('calendar.day_short.friday'),
-               $t('calendar.day_short.saturday'),
-               $t('calendar.day_short.sunday')
-       ];
+       // weekdays (reordered when first day of week is Sunday)
+       const weekDays = $derived.by(() => {
+               const base = [
+                       $t('calendar.day_short.monday'),
+                       $t('calendar.day_short.tuesday'),
+                       $t('calendar.day_short.wednesday'),
+                       $t('calendar.day_short.thursday'),
+                       $t('calendar.day_short.friday'),
+                       $t('calendar.day_short.saturday'),
+                       $t('calendar.day_short.sunday')
+               ];
+               return $settings.firstDayOfWeek === 'sunday' ? [base[6], ...base.slice(0, 6)] : base;
+       });
 
        // --- Swipe Navigation (month) ---
        let swipeActive = false;
index 91dfe8f370f4816a508e47579fef38c3cef73715..03ad5681a3185aaed20d397ce250bf490640f645 100644 (file)
                                                                                </div>
                                                                        </div>
 
+                                                                       <div id="FirstDayOfWeek">
+                                                                               {#if $tempSettings.firstDayOfWeek !== $settings.firstDayOfWeek}
+                                                                                       {@render unsavedChanges()}
+                                                                               {/if}
+                                                                               <h5>{$t('settings.first_day_of_week')}</h5>
+                                                                               <div class="form-text mt-2">
+                                                                                       {$t('settings.first_day_of_week.help_text')}
+                                                                               </div>
+                                                                               <select class="form-select w-auto" bind:value={$tempSettings.firstDayOfWeek}>
+                                                                                       <option value="sunday">{$t('weekdays.sunday')}</option>
+                                                                                       <option value="monday">{$t('weekdays.monday')}</option>
+                                                                               </select>
+                                                                       </div>
+
                                                                        <div id="aLookBack">
                                                                                {#if $tempSettings.useALookBack !== $settings.useALookBack || JSON.stringify(aLookBackYears
                                                                                                        .trim()
git clone https://git.99rst.org/PROJECT