mirror of
https://github.com/tomru/pfadi-bussle.git
synced 2026-03-04 15:07:13 +01:00
fix most type errors
still have a few things outstanding
This commit is contained in:
committed by
Thomas Ruoff
parent
c3d8c6f3e0
commit
90ac05a907
@@ -3,7 +3,13 @@ import moment from 'moment'
|
||||
const FRONTEND_FORMAT = 'DD.MM.YYYY'
|
||||
const BACKEND_FORMAT = 'YYYY-MM-DD'
|
||||
|
||||
export function getDays({ startDate, endDate }) {
|
||||
export function getDays({
|
||||
startDate,
|
||||
endDate,
|
||||
}: {
|
||||
startDate: moment.MomentInput
|
||||
endDate: moment.MomentInput
|
||||
}) {
|
||||
let currentDay = moment(startDate)
|
||||
const days = [dateFormatBackend(currentDay)]
|
||||
|
||||
@@ -20,31 +26,30 @@ export function getDays({ startDate, endDate }) {
|
||||
return days
|
||||
}
|
||||
|
||||
function dateFormat(date, format) {
|
||||
function dateFormat(date: moment.MomentInput, format: string) {
|
||||
if (!date) {
|
||||
return null
|
||||
}
|
||||
return moment(date).format(format)
|
||||
}
|
||||
|
||||
export function dateFormatBackend(date) {
|
||||
export function dateFormatBackend(date: moment.MomentInput) {
|
||||
return dateFormat(date, BACKEND_FORMAT)
|
||||
}
|
||||
|
||||
export function dateFormatFrontend(date) {
|
||||
export function dateFormatFrontend(date: moment.MomentInput) {
|
||||
return dateFormat(date, FRONTEND_FORMAT)
|
||||
}
|
||||
|
||||
function dateParse(string, format) {
|
||||
const date = moment(string, format)
|
||||
function dateParse(input: string, format: string) {
|
||||
const date = moment(input, format)
|
||||
if (date.isValid()) {
|
||||
// @ts-expect-error ts-migrate(2339) FIXME: Property 'getDate' does not exist on type 'Moment'... Remove this comment to see the full error message
|
||||
return date.getDate()
|
||||
return date.toDate()
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
export function dateParseFrontend(string) {
|
||||
return dateParse(string, FRONTEND_FORMAT)
|
||||
export function dateParseFrontend(input: string) {
|
||||
return dateParse(input, FRONTEND_FORMAT)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user