Daily Note plugin -- week of year incorrect?

What I am trying to do

I configured the Daily Notes plugin with “Date Format” set so that my daily notes are automatically placed in folders for year, month, and week of year. When it comes to how Sunday is treated I get different results depending on the moment.js coding used

1. Using “w” or “ww” for “week of year”

With this, Obsidian calculates that 2022-03-06 (a Sunday) is in the 11th week of the year.

2. Using “W” or “WW” for “week of year” (ISO version)

With this, Obsidian calculates that 2022-03-06 is in the 9th week of the year.

3. Summary

Neither calculation (and the resulting folder creation) is correct for Sunday 22022-03-06 or, as far as I can tell, for any other Sunday. Two issues

  1. AFAIK there is no setting for the core Daily Note plugin to tell Obsidian what the first day of the week is – e.g., “First day of week: Sunday”.
  2. Neither of the two formats shown above (“W or WW”, and “w or ww”) are interpreted correctly – i.e., the “correct” week of year for 2022-03-06 is “10” not "09 and not “11”.

Things I have tried

What I’ve tried is detailed above. What I do, every Sunday, is manually correct what seems to be to be an “error”.

There seems to be some inconsistency with how dates and durations are parsed in Obsidian and its plugins:

And:

Possibly to do with Luxon itself:

Hope @Licat and @Silver will be able to help.

Angel

1 Like

Thank you. I don’t think this is a duration calculation problem, but I can be wrong about that. I think it is either something wrong in moment.js or something in the way the first day of week is determined based on location information (locale).

1 Like

Hi.
I think (we all - including myself - “think” without some “technical” support or deep knowledge :slight_smile: ) the question is related with the differences between moment formats and iso/luxon formats. For example, intuitively, we think 1st January is related with the start of the first week of the year; we think all formats works in the same way; we think that all formats consider the first day of the week (Sunday? Monday?) in equal mode…
But all these are “wrong” assumptions. The rules for the first week of the year are different for moment and iso formats (that’s why some differences between the use of WW [iso] and ww [moment]. (For example, see iso rules: ISO week date - Wikipedia)
By my personal experience, by this year there’s a difference of one week from one format for the other. In your example you get the difference of two weeks and not only one. I think this is because another difference: to one format the new week starts in Sunday, to other starts in Monday (if you try to tomorrow date, maybe the difference is reduced to one week).
And there’re others differences related with “locale” date formats (informed by your system).
So, as a conclusion, if possible, it’s important to define and use always the same format. For example, if anyone use many dataview dql queries -which works with ison/luxon format - it’s recommend to use the daily notes title format with iso tokens…
But if anyone could explain this with a more “technical” language, we appreciate. :slight_smile:

1 Like

Indeed. Though wonder if there is any connection. Apologies if it looked as though I was trying to hijack your thread. I posted as I thought the issues might be related, and I am hoping that the extra info might help @Licat and @Silver. Might be barking up the wrong tree. Would be useful to get some official clarification for this.

Interesting thread.

Angel

1 Like

Please, don’t tag the devs. They will get flooded with notifications.

ISO weeks begin on monday and end on Sunday. The first week of the year always contains Jan 4th. Sunday 2022-03-06 is the last day of week 9.

The locale version depends on where you are. In the US, the first day of the week is Sunday and the first week of the year is the one that contains Jan 1st. Sunday 2022-03-06 is the first day of week 11.

2 Likes

the difference is what day is the first day of the week and which week is the first week of the year.

1 Like

If you want 2022-03-06 to be in week 10, then it sounds like you start weeks on Monday and count the first week of the year as the one that includes Jan 1.

Is your computer’s locale set correctly? That can affect how the calendar is set up because different places have different calendar customs. Check the language and/or time settings.

If that doesn’t help, the Calendar plugin enables you to set the first day of the week and/or override the system locale. Set it to Monday as use the “w” or “ww” syntax, and that should (hopefully) do what you want.

1 Like

If you start your week on a Monday, you need to select a localization that uses Monday as the first of the week in Calendar/Advanced Settings. Otherwise it will be a week off. I have mine set for en-gb.

You may have to close and reopen the vault after changing it, I don’t remember for sure.

Ah, yeah. I have Calendar set to en-gb but didn’t mention it (I guessed it was because I was using ISO weeks, but I must have run into the wrong-week problem).

Apologies.

Angel

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.