calculate number of weeks in a given year

前端 未结 9 2192
北恋
北恋 2020-12-04 01:48

I would like to get the number of weeks in any given year. Even though 52 is accepted as a generalised worldwide answer, the calendars for 2015,

9条回答
  •  渐次进展
    2020-12-04 02:03

    You can code yourself with the following information from ISO week date.

    On average, a year has 53 weeks every 5.6 years.

    The following 71 years in a 400-year cycle (add 2000 for current years) have 53 weeks. Years not listed have 52 weeks.

    004, 009, 015, 020, 026, 032, 037, 043, 048, 054, 060, 065, 071, 076, 082, 088, 093, 099, 105, 111, 116, 122, 128, 133, 139, 144, 150, 156, 161, 167, 172, 178, 184, 189, 195, 201, 207, 212, 218, 224, 229, 235, 240, 246, 252, 257, 263, 268, 274, 280, 285, 291, 296, 303, 308, 314, 320, 325, 331, 336, 342, 348, 353, 359, 364, 370, 376, 381, 387, 392, 398.

    You can use the above information to return 52 or 53 accordingly :)

提交回复
热议问题