microsoft / cpprestsdk

The C++ REST SDK is a Microsoft project for cloud-based client-server communication in native code using a modern asynchronous C++ API design. This project aims to help C++ developers connect to and interact with services.
Other
8.01k stars 1.66k forks source link

Leap year 400 #1565

Open Ooru opened 3 years ago

Ooru commented 3 years ago

https://github.com/microsoft/cpprestsdk/blob/41e7d0074b6cb5b22c89f835b4531d848ab66987/Release/src/utilities/asyncrt_utils.cpp#L732

if (year100 == 4)
{
    // this is the last day in a leap year
    year100 = 3;
}

https://github.com/microsoft/cpprestsdk/blob/41e7d0074b6cb5b22c89f835b4531d848ab66987/Release/src/utilities/asyncrt_utils.cpp#L771 const auto& monthTable = year_is_leap_year(year + 1900) ? cumulative_days_to_month_leap : cumulative_days_to_month;

barcharcraz commented 3 years ago

Can you add some description of the issue beyond a bunch code?

Ooru commented 3 years ago

Every 400 year is leap, so like already fixed in Line 732 for 4 years cycle, 4 * year100 will produce 1 day less then 400 years, you should correct: year100 = 3 and continue calculations.

"compute_year" method returns year from 1900 base, "year_is_leap_year" method argument is 0 based (or 1600 based)

This will strike around 2400 year

anishsingh935 commented 3 years ago

Hi I want to contribute on this issue if I allowed please

Ooru commented 3 years ago

Hi I want to contribute on this issue if I allowed please

From my side I permit. Sorry for long answer