Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { useToolbar } from './store/toolbar';
import IrdomToolbar from './components/IrdomToolbar.vue';
import CalendarDropdown from './views/timetable/CalendarDropdown.vue';
import { apiClient } from '@/api/';
import { parseLocalYmdDate } from './utils/date';

const profileStore = useProfileStore();
const toolbar = useToolbar();
Expand Down Expand Up @@ -44,7 +45,7 @@ onMounted(async () => {
>
<CalendarDropdown
v-if="/\d{4}-\d{2}-\d{2}/.test($route.path)"
:date="new Date($route.params.date as string)"
:date="parseLocalYmdDate($route.params.date as string)"
/>
</IrdomToolbar>
<RouterView />
Expand Down
5 changes: 5 additions & 0 deletions src/utils/date.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ import { lz } from './utils';
export const getWeekdayName = (date: Date, weekday: 'short' | 'long' = 'short') =>
date.toLocaleString('ru-RU', { weekday });

export const parseLocalYmdDate = (ymd: string) => {
const [year, month, day] = ymd.split('-').map(Number);
return new Date(year, month - 1, day);
};

export const getDateWithDayOffset = (date: Date, offset: number) => {
const d = new Date(date);
d.setDate(date.getDate() + offset);
Expand Down
4 changes: 2 additions & 2 deletions src/views/timetable/TimetableView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { computed, ref, watch } from 'vue';
import AsyncEventsList from './AsyncEventsList.vue';
import CalendarDropdown from './CalendarDropdown.vue';
import { useTimetableStore } from '@/store/timetable';
import { stringifyDate, getDateWithDayOffset } from '@/utils/date';
import { stringifyDate, getDateWithDayOffset, parseLocalYmdDate } from '@/utils/date';
import { LocalStorage, LocalStorageItem } from '@/models/LocalStorage';
import IrdomLayout from '@/components/IrdomLayout.vue';
import { useToolbar } from '@/store/toolbar';
Expand Down Expand Up @@ -39,7 +39,7 @@ toolbar.setup({
});

const date = computed(() => {
return new Date(route.params.date as string);
return parseLocalYmdDate(route.params.date as string);
});

// HACK: на каждое изменение даты обновляем компонент Suspense
Expand Down