Skip to content

Commit

Permalink
Merge pull request #99 from liamcain/use-startof-week-instead
Browse files Browse the repository at this point in the history
Use startof("week") for weekly notes so that DD displays correctly
  • Loading branch information
liamcain authored Jan 5, 2021
2 parents 1d0bd59 + 6b96027 commit ffb4401
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"id": "calendar",
"name": "Calendar",
"description": "Calendar view of your daily notes",
"version": "1.4.11",
"version": "1.4.12",
"author": "Liam Cain",
"authorUrl": "https://github.com/liamcain/",
"isDesktopOnly": false,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "calendar",
"version": "1.4.11",
"version": "1.4.12",
"description": "Calendar view of your daily notes",
"author": "liamcain",
"main": "main.js",
Expand Down
4 changes: 2 additions & 2 deletions src/io/weeklyNotes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ export function getWeeklyNote(date: Moment, settings: ISettings): TFile {
const { vault } = window.app;
const { format, folder } = getWeeklyNoteSettings(settings);

const endOfWeek = date.clone().endOf("week");
const baseFilename = endOfWeek.format(format);
const startOfWeek = date.clone().startOf("week");
const baseFilename = startOfWeek.format(format);

const fullPath = getNotePath(folder, baseFilename);
return vault.getAbstractFileByPath(fullPath) as TFile;
Expand Down
8 changes: 3 additions & 5 deletions src/view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,14 @@ export default class CalendarView extends ItemView {
): Promise<void> {
const { workspace } = this.app;

// Important: Use end of week in case week overlaps 2 years
// YYYY should use the NEW year.
const endOfWeek = date.clone().endOf("week");
const startOfWeek = date.clone().startOf("week");

const { format } = getWeeklyNoteSettings(this.settings);
const baseFilename = endOfWeek.format(format);
const baseFilename = startOfWeek.format(format);

if (!existingFile) {
// File doesn't exist
tryToCreateWeeklyNote(endOfWeek, inNewSplit, this.settings, () => {
tryToCreateWeeklyNote(startOfWeek, inNewSplit, this.settings, () => {
this.calendar.$set({ activeFile: baseFilename });
});
return;
Expand Down

0 comments on commit ffb4401

Please sign in to comment.