return (int) floorMod(julian + 1, 7) + 1; // sun=1, sat=7 case WEEK: long fmofw = firstMondayOfFirstWeek(year); if (julian < fmofw) { fmofw = firstMondayOfFirstWeek(year - 1);
return (int) floorMod(julian + 1, 7) + 1; // sun=1, sat=7 case WEEK: long fmofw = firstMondayOfFirstWeek(year); if (julian < fmofw) { fmofw = firstMondayOfFirstWeek(year - 1);
return (int) floorMod(julian + 1, 7) + 1; // sun=1, sat=7 case WEEK: long fmofw = firstMondayOfFirstWeek(year); if (julian < fmofw) { fmofw = firstMondayOfFirstWeek(year - 1);
/** Returns the ISO-8601 week number based on year, month, day. * Per ISO-8601 it is the Monday of the week that contains Jan 4, * or equivalently, it is a Monday between Dec 29 and Jan 4. * Sometimes it is in the year before the given year, sometimes after. */ private static int getIso8601WeekNumber(int julian, int year, int month, int day) { long fmofw = firstMondayOfFirstWeek(year); if (month == 12 && day > 28) { if (31 - day + 4 > 7 - ((int) floorMod(julian, 7) + 1) && 31 - day + (int) (floorMod(julian, 7) + 1) >= 4) { return (int) (julian - fmofw) / 7 + 1; } else { return 1; } } else if (month == 1 && day < 5) { if (4 - day <= 7 - ((int) floorMod(julian, 7) + 1) && day - ((int) (floorMod(julian, 7) + 1)) >= -3) { return 1; } else { return (int) (julian - firstMondayOfFirstWeek(year - 1)) / 7 + 1; } } return (int) (julian - fmofw) / 7 + 1; }
/** Returns the ISO-8601 week number based on year, month, day. * Per ISO-8601 it is the Monday of the week that contains Jan 4, * or equivalently, it is a Monday between Dec 29 and Jan 4. * Sometimes it is in the year before the given year, sometimes after. */ private static int getIso8601WeekNumber(int julian, int year, int month, int day) { long fmofw = firstMondayOfFirstWeek(year); if (month == 12 && day > 28) { if (31 - day + 4 > 7 - ((int) floorMod(julian, 7) + 1) && 31 - day + (int) (floorMod(julian, 7) + 1) >= 4) { return (int) (julian - fmofw) / 7 + 1; } else { return 1; } } else if (month == 1 && day < 5) { if (4 - day <= 7 - ((int) floorMod(julian, 7) + 1) && day - ((int) (floorMod(julian, 7) + 1)) >= -3) { return 1; } else { return (int) (julian - firstMondayOfFirstWeek(year - 1)) / 7 + 1; } } return (int) (julian - fmofw) / 7 + 1; }