When did China have a calendar in ancient times?

Xia dynasty.

In our country, it is said that there was a calendar in the era of the Yellow Emperor, but it was not enough. There is a legend of a rough calendar in the era of Emperor Yao, which may be slightly based. According to the ancient book Shang Shu Yao Dian in the Spring and Autumn Period, Emperor Yao organized a group of astronomical officials to observe the stars in the east, south, west and north for compiling calendars and forecasting seasons, but so far no information about calendars has been found.

The summer calendar is one of the six ancient calendars in China. It is said that this calendar originated in the Xia Dynasty. The original calendar rule has been lost. At present, we only know some contents from some ancient books: the month from the winter solstice is the next month as the calendar year, and the calendar year begins with the establishment of silver moon, namely Andrew (hereinafter referred to as Xia Zheng), and the whole number of 366 days is roughly adopted as one year, and the time difference is adjusted by subtraction and positive leap surplus.