Leap year problem

The leap year problem (also known as the leap year bug or the leap day bug) is a problem for both digital (computer-related) and non-digital documentation and data storage situations which results from the wrong calculation of which years are leap years, or from manipulating dates without regard to the difference between leap years and common years.
Categories.
Leap year bugs typically fall into two categories, based on the amount of impact they may have in real-world usage:
Examples.
Python.
The following Python code is an example of a Category 1 leap year bug. It will work properly until codice_1 becomes February 29. Then, it will attempt to create a February 29 of a common year, which does not exist. The codice_2 constructor will raise a codice_3 with the message "day is out of range for month".
from datetime import date
today = date.today()
later = today.replace(year = today.year + 1)
Windows C++.
The following Windows C++ code is an example of a Category 1 leap year bug. It will work properly until codice_4 becomes February 29. Then, it will attempt to create a February 29 of a common year, which does not exist. Passing this to any function that accepts a codice_5 struct will likely fail.
For example, the codice_6 call shown here will return an error code. Since that return value is unchecked (which is extremely common), this will result in codice_7 being left uninitialized.
SYSTEMTIME st;
FILETIME ft;
GetSystemTime(&st);
st.wYear++;
SystemTimeToFileTime(&st, &ft);
Microsoft C#.
The following .NET C# code is an example of a Category 1 leap year bug. It will work properly until codice_8 becomes February 29. Then, it will attempt to create a February 29 of a common year, which does not exist. The codice_9 constructor will throw an codice_10.
DateTime dt = DateTime.Now;
DateTime result = new DateTime(dt.Year + 1, dt.Month, dt.Day);
JavaScript.
The following JavaScript code is an example of a Category 2 leap year bug. It will work properly until codice_8 becomes February 29, such as on 2020-02-29. Then it will attempt to set the year to 2021. Since 2021-02-29 doesn't exist, the codice_12 object will roll forward to the next valid date, which is 2021-03-01.
var dt = new Date();
dt.setFullYear(dt.getFullYear() + 1);
Bad leap year algorithm (many languages).
The following code is an example of a leap year bug that is seen in many languages. It may cause either a Category 1 or Category 2 impact, depending on what the result is used for. It incorrectly assumes that a leap year occurs exactly every four years.
bool isLeapYear = year % 4 == 0;
The correct leap year algorithm is explained at Leap Year Algorithm.
Occurrences.
There have been many occurrences of leap year bugs: