[Date time Utils] Current weeknumber is incorrect
Forge component by João Marques
Application Type
Reactive

When trying out the demo of this application I see that the current weeknumber is incorrect.

When I choose the current date (04/12/2021) the weeknumber that is returned is 14. 

My Google calendar is saying that is it week 15.


But.. sometimes the weeknumber is correct.. for example 01/25/2020 returns week 4 and as I do check my Google Calendar it also says week 4.

Regards,

Bart

mvp_badge
MVP
Solution

Hi Bart,


As far as I know, this option affects how you see the Google calendar, in other words, the week day on the first column of the calendar.

In any case, I can only explain the rationale of my component and how it is based on the rule of the January 4th having to be in the week #1. Looking to January of 2021, we can see that Sunday 3rd of January will be week #1 if week starts on Sunday but week #53 of 2020 if it starts on Monday.


This affects the week numbers of subsequent dates, causing the difference you see in the component.


Kind Regards,
João

mvp_badge
MVP

Hi Bart,


The week number, besides the date, is also dependent on what is the first day of the week.


Why is the first day of the week important for getting the week number, you may ask?

Because, the 4th of January is always on the week #1. 


If the first day of the week is Sunday, then the week number is 15, as you can see on the image below. I guess Google Calendar's first day of the week is Sunday.



Kind Regards,
João

Hi João,

Setting the first day of the week to 0 (sunday) seems to work, but I am still not sure if this is correct. I did check the Google settings and it states Monday as the start of the week. Because of that I still think that setting the first day of the week to monday should result in week 15. Or am I incorrect on this one?

Regards,

Bart

mvp_badge
MVP
Solution

Hi Bart,


As far as I know, this option affects how you see the Google calendar, in other words, the week day on the first column of the calendar.

In any case, I can only explain the rationale of my component and how it is based on the rule of the January 4th having to be in the week #1. Looking to January of 2021, we can see that Sunday 3rd of January will be week #1 if week starts on Sunday but week #53 of 2020 if it starts on Monday.


This affects the week numbers of subsequent dates, causing the difference you see in the component.


Kind Regards,
João

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.