Skip to content

Commit

Permalink
Fix platform dependent call on weekInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
Acylation committed Nov 20, 2024
1 parent 0086e76 commit abbfef1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
7 changes: 3 additions & 4 deletions src/obsidianProjects.d.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import type { DataFrame } from "./lib/dataframe/dataframe";

declare global {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace Intl {
interface Locale {
weekInfo: {
firstDay: number;
};
weekInfo?: WeekInfo;
getWeekInfo?: () => WeekInfo;
}
}
type WeekInfo = { firstDay: number; weekend: number[]; minimalDays: number };
}

declare module "obsidian" {
Expand Down
12 changes: 10 additions & 2 deletions src/ui/views/Calendar/calendar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,15 @@ export function getFirstDayOfWeek(day: FirstDayOfWeek): number {
return 0;
case "monday":
return 1;
case "default":
return getLocale("obsidian").weekInfo.firstDay;
case "default": {
const obLocale = getLocale("obsidian");
if (obLocale.weekInfo) {
return obLocale.weekInfo.firstDay ?? 0;
}
if (typeof obLocale.getWeekInfo === "function") {
return obLocale.getWeekInfo().firstDay ?? 0;
}
return 0;
}
}
}

0 comments on commit abbfef1

Please sign in to comment.