mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 20:57:17 +01:00
Upgraded next and prisma. Replaced moment-timezone.
This commit is contained in:
parent
620a838173
commit
fccb1ddd9a
7 changed files with 3036 additions and 160 deletions
|
|
@ -1,11 +1,10 @@
|
|||
import { useState } from 'react';
|
||||
import { Dropdown, Item, Button, Flexbox } from 'react-basics';
|
||||
import moment from 'moment-timezone';
|
||||
import { useTimezone, useMessages } from 'components/hooks';
|
||||
import { getTimezone } from 'lib/date';
|
||||
import styles from './TimezoneSetting.module.css';
|
||||
|
||||
const timezones = moment.tz.names();
|
||||
const timezones = Intl.supportedValuesOf('timeZone');
|
||||
|
||||
export function TimezoneSetting() {
|
||||
const [search, setSearch] = useState('');
|
||||
|
|
|
|||
|
|
@ -1,11 +1,13 @@
|
|||
import { Metadata } from 'next';
|
||||
import Providers from './Providers';
|
||||
import '@fontsource/inter/300.css';
|
||||
import '@fontsource/inter/400.css';
|
||||
import '@fontsource/inter/500.css';
|
||||
import '@fontsource/inter/700.css';
|
||||
import '@fontsource/inter/800.css';
|
||||
import 'react-basics/dist/styles.css';
|
||||
import 'styles/index.css';
|
||||
import 'styles/variables.css';
|
||||
import '@umami/react-zen/dist/styles.css';
|
||||
|
||||
export default function ({ children }) {
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import moment from 'moment-timezone';
|
||||
import {
|
||||
addMinutes,
|
||||
addHours,
|
||||
|
|
@ -105,8 +104,17 @@ const DATE_FUNCTIONS = {
|
|||
},
|
||||
};
|
||||
|
||||
export function isValidTimezone(timezone: string) {
|
||||
try {
|
||||
Intl.DateTimeFormat(undefined, { timeZone: timezone });
|
||||
return true;
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export function getTimezone() {
|
||||
return moment.tz.guess();
|
||||
return Intl.DateTimeFormat().resolvedOptions().timeZone;
|
||||
}
|
||||
|
||||
export function parseDateValue(value: string) {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import debug from 'debug';
|
||||
import { Prisma } from '@prisma/client';
|
||||
import prisma from '@umami/prisma-client';
|
||||
import moment from 'moment-timezone';
|
||||
import { formatInTimeZone } from 'date-fns-tz';
|
||||
import { MYSQL, POSTGRESQL, getDatabaseType } from 'lib/db';
|
||||
import { SESSION_COLUMNS, OPERATORS, DEFAULT_PAGE_SIZE } from './constants';
|
||||
import { fetchWebsite } from './load';
|
||||
|
|
@ -75,7 +75,7 @@ function getDateSQL(field: string, unit: string, timezone?: string): string {
|
|||
|
||||
if (db === MYSQL) {
|
||||
if (timezone) {
|
||||
const tz = moment.tz(timezone).format('Z');
|
||||
const tz = formatInTimeZone(new Date(), timezone, 'yyyy-MM-dd HH:mm:ss');
|
||||
return `date_format(convert_tz(${field},'+00:00','${tz}'), '${MYSQL_DATE_FORMATS[unit]}')`;
|
||||
}
|
||||
return `date_format(${field}, '${MYSQL_DATE_FORMATS[unit]}')`;
|
||||
|
|
@ -90,7 +90,7 @@ function getDateWeeklySQL(field: string, timezone?: string) {
|
|||
}
|
||||
|
||||
if (db === MYSQL) {
|
||||
const tz = moment.tz(timezone).format('Z');
|
||||
const tz = formatInTimeZone(new Date(), timezone, 'yyyy-MM-dd HH:mm:ss');
|
||||
return `date_format(convert_tz(${field},'+00:00','${tz}'), '%w:%H')`;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import moment from 'moment-timezone';
|
||||
import * as yup from 'yup';
|
||||
import { isValidTimezone } from 'lib/date';
|
||||
import { UNIT_TYPES } from './constants';
|
||||
|
||||
export const TimezoneTest = yup
|
||||
|
|
@ -8,7 +8,7 @@ export const TimezoneTest = yup
|
|||
.test(
|
||||
'timezone',
|
||||
() => `Invalid timezone`,
|
||||
value => moment.tz.zone(value) !== null,
|
||||
value => isValidTimezone(value),
|
||||
);
|
||||
|
||||
export const UnitTypeTest = yup.string().test(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue