refactor: tighten types and reuse instrument UI
This commit is contained in:
@@ -9,13 +9,15 @@ function isValidPeriod(from: null | string, to: null | string) {
|
||||
);
|
||||
}
|
||||
|
||||
const moscowFormatter = new Intl.DateTimeFormat("en-CA", {
|
||||
day: "2-digit",
|
||||
month: "2-digit",
|
||||
timeZone: "Europe/Moscow",
|
||||
year: "numeric",
|
||||
});
|
||||
|
||||
function moscowDate(value: Date): string {
|
||||
const parts = new Intl.DateTimeFormat("en-CA", {
|
||||
day: "2-digit",
|
||||
month: "2-digit",
|
||||
timeZone: "Europe/Moscow",
|
||||
year: "numeric",
|
||||
}).formatToParts(value);
|
||||
const parts = moscowFormatter.formatToParts(value);
|
||||
|
||||
const part = (type: string) =>
|
||||
parts.find(item => item.type === type)?.value;
|
||||
|
||||
Reference in New Issue
Block a user