Open steynh opened 1 year ago
I just encountered the same bug. It has been some time since I used weekly notes with calendar, but a year ago they worked as designed.
Calender now shows and opens Weekly Notes form a year ago. It works fine when creating new weekly notes. I tried switching locale, deactivating periodic notes and daily notes.
Weekly Note format: yyyy/[KW]ww/[KW]ww Weekly Note Folder: Journal
Example: Journal/2023/KW43/KW43.md
Same for me... it finds past weeks even in a subfolder
The issue seems to be in getDateFromFile
function, it is using the basename of the each note file, which gives wrong year date if your weekly note file's basename does not include the year.
Here's a workaround for this: in .obsidian/plugins/calendar/main.js
search for function getDateFromFile
, patch the getDateFromFile
function by adding the following code after getSettings
object is declared:
if (granularity === 'week') {
const filePathParts = file.path.split('/');
const year = filePathParts[1];
const basename = filePathParts[filePathParts.length - 1];
const dateString = `${year}/${basename}`;
const formatString = `YYYY/${getSettings[granularity]()
.format.split('/')
.pop()}[.md]`;
return window.moment(dateString, formatString, true);
}
restarting obsidian after this change should fix the problem. (you might have to tweak the code a bit depending on your format for weekly note. mine is gggg/MM/[Week]-w
)
@rajrajhans Thanks for the tip... I've adapted it to my particular folder setup. Although I've found that the problem seems to be associated with momentjs not parsing correctly the default format string gggg-[W]WW
in getDateFromFile
function:
const format = getSettings[granularity]().format.split("/").pop();
const noteDate = window.moment(file.basename, format, true);
Changing it in Periodic Notes settings to GGGG-[W]WW
sets the calendar plugin to work as expected. It should work regarding the case of the format, maybe an outdated momentjs library embedded in Obsidian?
Changing it in Periodic Notes settings to
GGGG-[W]WW
sets the calendar plugin to work as expected. It should work regarding the case of the format, maybe an outdated momentjs library embedded in Obsidian?
Thanks @Inmovilizame. This did the trick.
Describe the bug
Clicking on a week opens that week, but then a year earlier.
Steps to reproduce
Expected behavior
Expected to open the "2023-W40" note.
Environment (please specify)
This bug was introduced recently.
OS
macOS
Obsidian Version (e.g. v0.10.6)
v1.4.12