Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Fixed month calculating issue of calendars(#7666) #7769

Merged
merged 1 commit into from
Oct 22, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ internal virtual int GetDatePart(long ticks, int part)
int[] days = leapYear ? DaysToMonth366 : DaysToMonth365;
// All months have less than 32 days, so n >> 5 is a good conservative
// estimate for the month
int m = n >> 5 + 1;
int m = (n >> 5) + 1;
// m = 1-based month number
while (n >= days[m]) m++;
// If month was requested, return it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ internal virtual int GetDatePart(long ticks, int part)
int[] days = leapYear ? DaysToMonth366 : DaysToMonth365;
// All months have less than 32 days, so n >> 5 is a good conservative
// estimate for the month
int m = n >> 5 + 1;
int m = (n >> 5) + 1;
// m = 1-based month number
while (n >= days[m]) m++;
// If month was requested, return it
Expand Down
2 changes: 1 addition & 1 deletion src/mscorlib/corefx/System/Globalization/JulianCalendar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ internal static int GetDatePart(long ticks, int part)
int[] days = leapYear ? s_daysToMonth366 : s_daysToMonth365;
// All months have less than 32 days, so n >> 5 is a good conservative
// estimate for the month
int m = n >> 5 + 1;
int m = (n >> 5) + 1;
// m = 1-based month number
while (n >= days[m]) m++;
// If month was requested, return it
Expand Down
2 changes: 1 addition & 1 deletion src/mscorlib/src/System/DateTime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ private int GetDatePart(int part) {
int[] days = leapYear? DaysToMonth366: DaysToMonth365;
// All months have less than 32 days, so n >> 5 is a good conservative
// estimate for the month
int m = n >> 5 + 1;
int m = (n >> 5) + 1;
// m = 1-based month number
while (n >= days[m]) m++;
// If month was requested, return it
Expand Down
2 changes: 1 addition & 1 deletion src/mscorlib/src/System/Globalization/GregorianCalendar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ internal virtual int GetDatePart(long ticks, int part)
int[] days = leapYear? DaysToMonth366: DaysToMonth365;
// All months have less than 32 days, so n >> 5 is a good conservative
// estimate for the month
int m = n >> 5 + 1;
int m = (n >> 5) + 1;
// m = 1-based month number
while (n >= days[m]) m++;
// If month was requested, return it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ internal virtual int GetDatePart(long ticks, int part)
int[] days = leapYear? DaysToMonth366: DaysToMonth365;
// All months have less than 32 days, so n >> 5 is a good conservative
// estimate for the month
int m = n >> 5 + 1;
int m = (n >> 5) + 1;
// m = 1-based month number
while (n >= days[m]) m++;
// If month was requested, return it
Expand Down
2 changes: 1 addition & 1 deletion src/mscorlib/src/System/Globalization/JulianCalendar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ static internal int GetDatePart(long ticks, int part)
int[] days = leapYear? DaysToMonth366: DaysToMonth365;
// All months have less than 32 days, so n >> 5 is a good conservative
// estimate for the month
int m = n >> 5 + 1;
int m = (n >> 5) + 1;
// m = 1-based month number
while (n >= days[m]) m++;
// If month was requested, return it
Expand Down