Oprava lokalizace datumu
All checks were successful
ci/woodpecker/push/workflow Pipeline was successful

This commit is contained in:
Martin Berka 2025-03-03 10:20:41 +01:00
parent 68bafa808c
commit 999a517404
3 changed files with 5 additions and 3 deletions

View File

@ -51,7 +51,7 @@ FROM ${NODE_VERSION}
RUN apk add --no-cache tzdata RUN apk add --no-cache tzdata
ENV TZ=Europe/Prague \ ENV TZ=Europe/Prague \
LANG=cs_CZ.UTF-8 \ LC_ALL=cs_CZ.UTF-8 \
NODE_ENV=production NODE_ENV=production
WORKDIR /app WORKDIR /app

View File

@ -4,7 +4,7 @@ FROM ${NODE_VERSION}
RUN apk add --no-cache tzdata RUN apk add --no-cache tzdata
ENV TZ=Europe/Prague \ ENV TZ=Europe/Prague \
LANG=cs_CZ.UTF-8 \ LC_ALL=cs_CZ.UTF-8 \
NODE_ENV=production NODE_ENV=production
WORKDIR /app WORKDIR /app

View File

@ -1,5 +1,7 @@
import { Choices, LocationKey } from "../../types"; import { Choices, LocationKey } from "../../types";
const DAY_OF_WEEK_FORMAT = new Intl.DateTimeFormat(undefined, {weekday: 'long'});
/** Vrátí datum v ISO formátu. */ /** Vrátí datum v ISO formátu. */
export function formatDate(date: Date, format?: string) { export function formatDate(date: Date, format?: string) {
let day = String(date.getDate()).padStart(2, '0'); let day = String(date.getDate()).padStart(2, '0');
@ -15,7 +17,7 @@ export function getHumanDate(date: Date) {
let currentDay = String(date.getDate()).padStart(2, '0'); let currentDay = String(date.getDate()).padStart(2, '0');
let currentMonth = String(date.getMonth() + 1).padStart(2, "0"); let currentMonth = String(date.getMonth() + 1).padStart(2, "0");
let currentYear = date.getFullYear(); let currentYear = date.getFullYear();
let currentDayOfWeek = date.toLocaleDateString("CZ-cs", { weekday: 'long' }); let currentDayOfWeek = DAY_OF_WEEK_FORMAT.format(date);
return `${currentDay}.${currentMonth}.${currentYear} (${currentDayOfWeek})`; return `${currentDay}.${currentMonth}.${currentYear} (${currentDayOfWeek})`;
} }