|
@@ -1,6 +1,7 @@
|
|
|
<script lang="ts">
|
|
<script lang="ts">
|
|
|
import type { AppointmentDateTimes } from '$lib/dbdata';
|
|
import type { AppointmentDateTimes } from '$lib/dbdata';
|
|
|
import { isSameDate } from '$lib/funcs';
|
|
import { isSameDate } from '$lib/funcs';
|
|
|
|
|
+ import { t } from '$lib/translations';
|
|
|
import moment, { type Moment } from 'moment';
|
|
import moment, { type Moment } from 'moment';
|
|
|
import { onMount } from 'svelte';
|
|
import { onMount } from 'svelte';
|
|
|
|
|
|
|
@@ -28,16 +29,21 @@
|
|
|
* Updates the calendar display by calculating the days of the current month.
|
|
* Updates the calendar display by calculating the days of the current month.
|
|
|
*/
|
|
*/
|
|
|
const renderCalendar = (): void => {
|
|
const renderCalendar = (): void => {
|
|
|
- const mDate: Moment = moment(currentDate);
|
|
|
|
|
|
|
+ const mDate: Moment = moment(currentDate).locale("de");
|
|
|
const year: number = currentDate.getFullYear();
|
|
const year: number = currentDate.getFullYear();
|
|
|
const month: number = mDate.month();
|
|
const month: number = mDate.month();
|
|
|
|
|
|
|
|
|
|
+ let locale: string = "en-US";
|
|
|
|
|
+
|
|
|
|
|
+ if (navigator.language.includes("de")) locale = "de";
|
|
|
|
|
+
|
|
|
// make sure to properly translate this
|
|
// make sure to properly translate this
|
|
|
- currentMonth = currentDate.toLocaleDateString('en-US', { month: 'long', year: 'numeric' });
|
|
|
|
|
|
|
+ currentMonth = currentDate.toLocaleDateString(locale, { month: 'long', year: 'numeric' });
|
|
|
|
|
|
|
|
const firstDayOfMonth: Date = new Date(year, month, 1);
|
|
const firstDayOfMonth: Date = new Date(year, month, 1);
|
|
|
const lastDayOfMonth: Date = new Date(year, month + 1, 0);
|
|
const lastDayOfMonth: Date = new Date(year, month + 1, 0);
|
|
|
- const firstDayIndex: number = firstDayOfMonth.getDay();
|
|
|
|
|
|
|
+ let firstDayIndex: number = firstDayOfMonth.getDay() - 1;
|
|
|
|
|
+ if (firstDayIndex === -1) firstDayIndex = 6;
|
|
|
const daysInMonth: number = lastDayOfMonth.getDate();
|
|
const daysInMonth: number = lastDayOfMonth.getDate();
|
|
|
|
|
|
|
|
// Reset days array
|
|
// Reset days array
|
|
@@ -97,13 +103,13 @@
|
|
|
</div>
|
|
</div>
|
|
|
<div class="date-picker-grid">
|
|
<div class="date-picker-grid">
|
|
|
<!-- Days of the week -->
|
|
<!-- Days of the week -->
|
|
|
- <div class="date-picker-day">Sun</div>
|
|
|
|
|
- <div class="date-picker-day">Mon</div>
|
|
|
|
|
- <div class="date-picker-day">Tue</div>
|
|
|
|
|
- <div class="date-picker-day">Wed</div>
|
|
|
|
|
- <div class="date-picker-day">Thu</div>
|
|
|
|
|
- <div class="date-picker-day">Fri</div>
|
|
|
|
|
- <div class="date-picker-day">Sat</div>
|
|
|
|
|
|
|
+ <div class="date-picker-day">{$t("common.monday-short")}</div>
|
|
|
|
|
+ <div class="date-picker-day">{$t("common.tuesday-short")}</div>
|
|
|
|
|
+ <div class="date-picker-day">{$t("common.wednesday-short")}</div>
|
|
|
|
|
+ <div class="date-picker-day">{$t("common.thursday-short")}</div>
|
|
|
|
|
+ <div class="date-picker-day">{$t("common.friday-short")}</div>
|
|
|
|
|
+ <div class="date-picker-day">{$t("common.saturday-short")}</div>
|
|
|
|
|
+ <div class="date-picker-day">{$t("common.sunday-short")}</div>
|
|
|
|
|
|
|
|
<!-- Render days -->
|
|
<!-- Render days -->
|
|
|
{#each days as { day, isActive, isAvailable }, index}
|
|
{#each days as { day, isActive, isAvailable }, index}
|