diff --git a/.eslintrc.json b/.eslintrc.json index 0438f4b5..19d025bc 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -8,7 +8,8 @@ "files": ["**.ts"], "rules": { "no-useless-constructor": "off", - "@typescript-eslint/no-useless-constructor": "error" + "@typescript-eslint/no-useless-constructor": "error", + "jsdoc/require-returns-type": "off" } }, { diff --git a/lib/date.ts b/lib/date.ts index 98ee3ef7..39185176 100644 --- a/lib/date.ts +++ b/lib/date.ts @@ -8,15 +8,17 @@ import { getCanonicalLocale } from './locale' declare let window: Nextcloud.v27.WindowWithGlobals +export type WeekDay = 0 | 1 | 2 | 3 | 4 | 5 | 6 + /** * Get the first day of the week * - * @return {number} + * @return The first day where 0 is Sunday, 1 is Monday etc. */ -export function getFirstDay(): number { +export function getFirstDay(): WeekDay { // Server rendered if (typeof window.firstDay !== 'undefined') { - return window.firstDay + return window.firstDay as WeekDay } // Try to fallback to Intl @@ -33,7 +35,7 @@ export function getFirstDay(): number { const weekInfo: WeekInfo = intl.getWeekInfo?.() ?? intl.weekInfo if (weekInfo) { // Convert 1..7 to 0..6 format - return weekInfo.firstDay % 7 + return weekInfo.firstDay % 7 as WeekDay } // Fallback to Monday