mirror of
https://github.com/tomru/pfadi-bussle.git
synced 2026-03-04 15:07:13 +01:00
infer return type of functions
This commit is contained in:
@@ -4,7 +4,7 @@ import { utcToZonedTime } from 'date-fns-tz'
|
||||
const FRONTEND_FORMAT = 'dd.MM.yyyy'
|
||||
const BACKEND_FORMAT = 'yyyy-MM-dd'
|
||||
|
||||
export function daysFormatFrontend(days: string[]) {
|
||||
export function daysFormatFrontend(days: string[]): string {
|
||||
if (days.length === 0) {
|
||||
return ''
|
||||
}
|
||||
@@ -24,7 +24,7 @@ export function getDays({
|
||||
}: {
|
||||
startDate: Date
|
||||
endDate: Date
|
||||
}) {
|
||||
}): string[] {
|
||||
let currentDay = new Date(startDate.getTime())
|
||||
const days = [dateFormatBackend(currentDay)]
|
||||
|
||||
@@ -40,22 +40,22 @@ export function getDays({
|
||||
return days
|
||||
}
|
||||
|
||||
function dateFormat(date: Date, formatString: string) {
|
||||
function dateFormat(date: Date, formatString: string): string {
|
||||
if (!date) {
|
||||
return null
|
||||
}
|
||||
return format(date, formatString)
|
||||
}
|
||||
|
||||
export function dateFormatBackend(date: Date) {
|
||||
export function dateFormatBackend(date: Date): string {
|
||||
return dateFormat(date, BACKEND_FORMAT)
|
||||
}
|
||||
|
||||
export function dateFormatFrontend(date: Date) {
|
||||
export function dateFormatFrontend(date: Date): string {
|
||||
return dateFormat(date, FRONTEND_FORMAT)
|
||||
}
|
||||
|
||||
function dateParse(input: string, formatString: string) {
|
||||
function dateParse(input: string, formatString: string): Date {
|
||||
const date = parse(input, formatString, new Date())
|
||||
if (date.getTime() !== NaN) {
|
||||
return date
|
||||
@@ -64,11 +64,11 @@ function dateParse(input: string, formatString: string) {
|
||||
return null
|
||||
}
|
||||
|
||||
export function dateParseFrontend(input: string) {
|
||||
export function dateParseFrontend(input: string): Date {
|
||||
return dateParse(input, FRONTEND_FORMAT)
|
||||
}
|
||||
|
||||
export function nowInTz(timezone = 'Europe/Berlin') {
|
||||
export function nowInTz(timezone = 'Europe/Berlin'): Date {
|
||||
const now = new Date()
|
||||
return utcToZonedTime(now, timezone)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user