Does WeekInYear method consider browser local

2 posts, 0 answers
  1. Kumeri
    Kumeri avatar
    13 posts
    Member since:
    Jul 2018

    Posted 07 May 2019 Link to this post


    i would like to know whether the logic in method consider the browser local when calculating the week number. 

    Because the first day of the first week does not always fall on the first day of the year
    For example, in the US, the week that contains Jan 1 is always the first week. In the US, weeks also start on Sunday. If Jan 1 was a Monday, Dec 31 would belong to the same week as Jan 1, and thus the same week-year as Jan 1. Dec 30 would have a different week-year than Dec 31.

    And i know that we can pass a parameter to method for weekStart(number between 0 to 6), If you consider browser local in method logic, how ti will behave once we also input weekStart as a paramter?

  2. Veselin Tsvetanov
    Veselin Tsvetanov avatar
    1234 posts

    Posted 09 May 2019 Link to this post


    Тhe logic in the method considers the Kendo Culture, which has been configured for the current page. It does not take into account the browser / machine culture. That is why, if you use different Kendo Culture (which is also responsible for the first day of the week configuration), you may end up with different results. Here you could find a small sample demonstrating that. When using the ​bg-BG culture, 1st of  January 2017 will be reported to belong to the 52nd week of year 2016. With the default culture (en-US), it will be reported to belong to the 1st week of year 2017. The difference comes from the fact that the Kendo implementation follows the ISO-8601 standard, according to which the first week of the year is the week that contains that year's first Thursday (='First 4-day week').

    Therefore, for the Bulgarian culture, in which the first day of the week is Monday, 1st of January 2017 will be the last day of a week. That week will hold only one day from the year 2017. Therefore, it will be considered to belong to the previous year (2016) and it will be its last week.

    The en-US culture, however, has Sunday as its first day. Therefore, 1st of January will belong to the week 1-7th January 2017. There are 7 days of the new year in that week (7 >= 4). That is why, it will be the first week of the year.

    The first day of the week can be overridden by using the second parameter of the method call. This way, the following call: Date(2017, 0, 1), 0);

    will always return 1, independent from the Kendo Culture that is being used.

    Veselin Tsvetanov
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top