Longer real answer: The current Chinese calendar is not 4721 years old. It was developed right at the end of the Ming Dynasty, in the 17th century AD. The current calendar is based on direct observations of the exact positions of the sun and the moon, and so it is inherently precise and future-proof.
Since I am a massive calendar nerd, I will now delve into the gory details.
The civil day runs from midnight to midnight, Chinese Standard Time.
Each month begins on the day of the new moon. It doesn't matter if the new moon happens one second after midnight or one second before the day ends, if it falls on that day, then that day is the start of the month.
A year usually has 12 months, but sometimes has 13 to keep things aligned with the sun. The ecliptic is divided into 24 equal parts called solar terms (jieqi), of which the even-numbered ones are called major solar terms (zhongqi). The zhongqi include the instants of the solstices and equinoxes. A month normally contains a zhongqi within it; if a year has a leap month, the leap month is the first month without a zhongqi. The leap month has the same name and number as the preceding regular month. (If the Gregorian calendar did leap month, it would be like going January, February, March, Extra March, April...)
The 11th month of the year, by definition, is the one that contains the southern solstice (which in China is the winter solstice). If there are 12 months between that month and the 11th month of the next year, then the year to come is a normal year with 12 months; if there are 13, then one of those 13 months is a leap month. Most commonly, the leap month is part of the year to come, but occasionally it falls after the 11th or 12th month of the year coming to an end.
The calendar year has nothing to do with the age of the calendar; it is the number of years since some important event. The Gregorian calendar, for example is on year 2023 as of this writing, but it is not 2,023 years old; it was introduced in 1568, but counts years from the birth of Jesus (or rather the nominal birth; historians and Bible scholars generally agree that Jesus was actually born closer to 4BC). The earliest known Chinese calendars date to the Shang dynasty, and assumed a tropical year of 365¼ days. Under the influence of Indian astronomical treatises, calendars were designed that closely matched the length of the sidereal year, but Chinese astronomers noticed in the early Han dynasty that the tropical year is slightly shorter than the sidereal year, and adjusted their values to match.
Calendar reform was seen as a duty of the emperor, as it was right and proper to make timekeeping accord ever closer with the seasons. To this end, every emperor was expected to commission at least one calendar refinement, though not all of them did so. Such was the importance of accurate timekeeping that foreigners were invited to bring astronomical knowledge and methods to China. Muslims astronomers in particular were sought-after due to the impressive astronomical knowledge of the Muslim world.
Jesuit missionaries arrived in China during the reign of Emperor Deyue, and impressed court officials with European mathematical and engineering insights. The emperor heard about this and decided to put them to a test. He tasked the Christians with predicting the exact time of the next eclipse, and also tasked the Buddhist and Muslim astronomers in his court with the same task. The Christians were naturally eager to impress the emperor, and quite reasonably figured that converting him would do a great deal to Christianise the rest of China. The Christians knew about the mighty logarithm, and their calculation of the time of the eclipse was most accurate. The emperor was impressed, and tasked them with designing the latest iteration of the calendar, which is still in use today. He was also initially receptive to Christianity until they got to the part where he would only be allowed to have one wife at a time, and no concubines. Upon hearing this, he decided that Christianity wasn't for him, and Buddhism was really more his speed.
So if I got this right, instead of defining the number of days in a year like Julian calendar, the Chinese calendar goes off lunar cycles with extra months as necessary (according to lunar and solstice cycle). Thus it naturally didn't run into the problem the Julian calendar had with defined number of days. Right?
Same way you get to be any other kind of nerd - by getting really interesting in something.
In my case, I'd had some interest in calendars for a while, ever since I came across this converter. I'd also always wanted to learn programming, but my previous efforts just kind of fizzled out.
In 2020, I had some COVID-related downtime, and decided to use it to learn programming again. I worked my way through a book on Python, and when I finished, decided that the best way to practice was to write a real programme. I figured an extensive calendar converter would be a good way to learn, since it's all just maths. Writing a converter involved doing research to learn how various calendars work, writing code, and comparing it to existing converters and historical data. This in turn led to finding out about more and more obscure calendars, and I just became obsessed with tracking down vague hints and references.
The Chinese calendar in particular took me about a year of admittedly sporadic work, plus a lot of frustration, to figure out, because while there are plenty of descriptions, most of them are poorly-worded and not very descriptive. I also ended up having to write a whole library in Fortran to calculate the position of the sun and the moon. Yes, Fortran.
Right now I'm trying to figure out how traditional Indian calendars work, which is a whole challenge because they're even less-well documented than the Chinese calendars, and what documentation I can find tends to result in dates that don't match official dates.
I've put my notes on the calendars I've so far implemented here, with sources. Some sources are sketchy, but were all I could find.