Skip to content

Commit

Permalink
Extract dayjs setup into file
Browse files Browse the repository at this point in the history
  • Loading branch information
schroda committed May 21, 2024
1 parent d889be5 commit 09ee5e6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
10 changes: 1 addition & 9 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,12 @@

import { StrictMode } from 'react';
import { createRoot } from 'react-dom/client';
import dayjs from 'dayjs';
import customParseFormat from 'dayjs/plugin/customParseFormat';
import { App } from '@/App';
import '@/index.css';
// roboto font
import '@fontsource/roboto';
import { defaultPromiseErrorHandler } from '@/util/defaultPromiseErrorHandler.ts';
import { loadDayJsLocale } from '@/util/language.tsx';

dayjs.extend(customParseFormat);

loadDayJsLocale(navigator.language).then(() => {
dayjs.locale(navigator.language);
});
import '@/lib/dayjs/Setup.ts';

if ('serviceWorker' in navigator) {
navigator.serviceWorker.ready.then((registration) => {
Expand Down
17 changes: 17 additions & 0 deletions src/lib/dayjs/Setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* Copyright (C) Contributors to the Suwayomi project
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/

import dayjs from 'dayjs';
import customParseFormat from 'dayjs/plugin/customParseFormat';
import { loadDayJsLocale } from '@/util/language.tsx';

dayjs.extend(customParseFormat);

loadDayJsLocale(navigator.language).then(() => {
dayjs.locale(navigator.language);
});

0 comments on commit 09ee5e6

Please sign in to comment.