Files
web/apps/scandic-web/utils/dateFormatting.ts
Anton Gunnarsson 7e97b74c18 Merged in chore/remove-unused-code (pull request #2229)
Remove unused code

* Remove unused scandic-web files

* Remove unused exports


Approved-by: Joakim Jäderberg
2025-05-30 12:41:18 +00:00

22 lines
633 B
TypeScript

import d from "dayjs"
import type { Lang } from "@/constants/languages"
/**
* Get the localized month name for a given month index and language
* @param monthIndex - The month index (1-12)
* @param lang - the language to use, Lang enum
* @returns The localized month name
*/
export function getLocalizedMonthName(monthIndex: number, lang: Lang) {
const monthName = new Date(2024, monthIndex - 1).toLocaleString(lang, {
month: "long",
})
return monthName.charAt(0).toUpperCase() + monthName.slice(1)
}
export function getNumberOfNights(startDate: Date, endDate: Date) {
return d(endDate).diff(startDate, "day")
}