obsidian-calendar-plugin
obsidian-calendar-plugin copied to clipboard
Follow ISO-8601 Standard Convention for W01
Is your feature request related to a problem? Please describe.
Describe the solution you'd like This plugins week numbering system does not follow standard ISO-8601 date conventions with regards to defining which days fall into week-1 (W01) of a given calendar year.
Per Wikipedia (sorry, I don't have access to the original document): "_As a consequence, if 1 January is on a Monday, Tuesday, Wednesday or Thursday, it is in week 01. If 1 January is on a Friday, Saturday or Sunday, it is in week 52 or 53 of the previous year (there is no week 00). 28 December is always in the last week of its year....
The ISO week-numbering year starts at the first day (Monday) of week 01 and ends at the Sunday before the new ISO year (hence without overlap or gap). It consists of 52 or 53 full weeks. The first ISO week of a year may have up to three days that are actually in the Gregorian calendar year that is ending; if three, they are Monday, Tuesday and Wednesday. Similarly, the last ISO week of a year may have up to three days that are actually in the Gregorian calendar year that is starting; if three, they are Friday, Saturday, and Sunday. The Thursday of each ISO week is always in the Gregorian calendar year denoted by the ISO week-numbering year. _"
For the 2022 calendar year, January 1st falls on a Saturday meaning that it should be included in the last week of 2021. Therefore, Monday January 3rd should be W01 for 2022. However, as shown in the image below, Monday January 3rd falls into W02
Describe alternatives you've considered If this change is undesirable as a default, it would be nice to at least allow for users to dictate which day defines W01 in a calendar year.
Additional context
Same problem for me. I have Obsidian on three systems. Windows, Android and Ubuntu. This problem shows only on my Windows system. Maybe there is a problem with time syncing for Windows.
I change one thing in the calendar settings in Obsidian. The Override locale option. Here I change the option to my regional settings, so it matched my Windows system. New starting the app and after this it's working perfect.
Here is the Option.
Same issue here. Here's a related forum thread:
https://forum.obsidian.md/t/incorrect-week-numbers-for-weekly-notes-calendar-plugin/20358/3
Confirming same issue. I just spent 2 hour pulling my hair out trying to set up a daily/weekly/monthly notes capability where dates were being calculated incorrectly. I assumed the week number on the calendar view was correct, but it is not.
Currently (Friday Feb 4th 2022) the actual week number is 04 but the Calendar plugin is using 05.
To clarify -- this means the Calendar plugin is broken and all weeks will be off by 1 going forward until this is fixed. Users will not be able to trust the week number that is displayed.
Moment returns the correct week number. Not sure how the week number is being calculated inside the plugin for the view.
Workaround for US users: Change locale to one of the en-*
other than en-ca
since it also exhibits the same behavior as en
.
In my case I changed to en-uk
and it is displaying the correct week in the Calendar view now, and generation of weekly notes appears to work correctly. en-au
also works. However, en-ca
exhibits the faulty behavior.
en-us
also shows the wrong week numbers
I don't even use the weekly notes, I just like the week number in my calendar... I'm hoping that will still show after the move when I don't install "Periodic Notes" (even better if the week numbers aren't buttons)
It's April now and this needs to be fixed, and not simply worked around.
Ran into the same issue. Locals en-au
and en-ca
seem to be broken, en-uk
doesn't exist, and en-gb
fixes it, assuming I override the week start to Sunday. If I set the week start to Monday, it shifts all the number down another week.
Related #248 Related #247 Related #222 Related #206 Related #183 Related #128
Related liamcain/obsidian-periodic-notes#95 Related liamcain/obsidian-periodic-notes#55 Related liamcain/obsidian-periodic-notes#41 Related liamcain/obsidian-periodic-notes#17 Related liamcain/obsidian-periodic-notes#13
By chance could the suggestion used in https://github.com/moment/moment/issues/5699, be the solution? It looks to me like a setting needs to be added to force ISO-8601.
I have not tested the code on that, but I wouldn't mind trying.
This would require the following logice to either use the current logic if unchecked, or moment.isoWeek();
https://github.com/liamcain/obsidian-calendar-ui/blob/master/src/utils.ts#L42
@pjkaufman
I tried your idea and it works.
The object 'data' is clone of moment() and moment is not in the scope, so replacing data.week() -> data.isoWeek() worked for me. Thanks!
@softmare , that is great! Now maybe one of the maintainers or a dev more familiar with how these modules interact can see about adding an option to use the iso value.