total-weeks.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. == Total weeks in years of 1970 to 2050, from PHP: ==
  3. $arr = [];
  4. function getIsoWeeksInYear($year) {
  5. $date = new DateTime($year.'-12-31');
  6. return ($date->format("W") === "53" ? 53 : 52);
  7. }
  8. for ($i = 1970; $i < 2050; $i++){
  9. array_push($arr, getIsoWeeksInYear($i));
  10. }
  11. echo json_encode($arr);
  12. */
  13. var totalWeeks = [53, 52, 52, 52, 52, 52, 53, 52, 52, 52, 52, 53, 52, 52, 52, 52, 52, 53, 52, 52, 52, 52, 53, 52, 52, 52, 52, 52, 53, 52, 52, 52, 52, 52, 53, 52, 52, 52, 52, 53, 52, 52, 52, 52, 52, 53, 52, 52, 52, 52, 53, 52, 52, 52, 52, 52, 53, 52, 52, 52, 52, 52, 53, 52, 52, 52, 52, 53, 52, 52, 52, 52, 52, 53, 52, 52, 52, 52, 53, 52];
  14. /*
  15. == Number of week in year for 1st of January ==
  16. $arr = [];
  17. function getWeek($year) {
  18. $date = new DateTime($year.'-01-01');
  19. return $date->format("W");
  20. }
  21. for ($i = 1971; $i < 2051; $i++){
  22. array_push($arr, getWeek($i));
  23. }
  24. echo json_encode($arr);
  25. */
  26. var januaryWeekStart = [53, 52, 1, 1, 1, 1, 53, 52, 1, 1, 1, 53, 52, 52, 1, 1, 1, 53, 52, 1, 1, 1, 53, 52, 52, 1, 1, 1, 53, 52, 1, 1, 1, 1, 53, 52, 1, 1, 1, 53, 52, 52, 1, 1, 1, 53, 52, 1, 1, 1, 53, 52, 52, 1, 1, 1, 53, 52, 1, 1, 1, 1, 53, 52, 1, 1, 1, 53, 52, 52, 1, 1, 1, 53, 52, 1, 1, 1, 53, 52];
  27. // US and EU start week in different days, resp sunday and monday
  28. // this is a sample to make sure the js-calendar can produce the correct week numbers
  29. var weekNumbersUS = {
  30. 2015: [1, 6, 10, 14, 18, 23, 27, 31, 36, 40, 45, 49],
  31. 2016: [1, 6, 10, 14, 19, 23, 27, 32, 36, 40, 45, 49],
  32. 2017: [1, 5, 9, 13, 18, 22, 26, 31, 35, 40, 44, 48],
  33. 2018: [1, 5, 9, 14, 18, 22, 27, 31, 35, 40, 44, 48],
  34. 2019: [1, 5, 9, 14, 18, 22, 27, 31, 36, 40, 44, 49],
  35. 2020: [1, 5, 10, 14, 18, 23, 27, 31, 36, 40, 45, 49],
  36. 2021: [1, 6, 10, 14, 18, 23, 27, 32, 36, 40, 45, 49],
  37. 2022: [1, 6, 10, 14, 19, 23, 27, 32, 36, 40, 45, 49],
  38. 2023: [1, 5, 9, 13, 18, 22, 26, 31, 35, 40, 44, 48]
  39. }
  40. module.exports = {
  41. totalWeeks: totalWeeks,
  42. januaryWeekStart: januaryWeekStart,
  43. i18n: weekNumbersUS
  44. }