Counting the days, revisited

Many years ago I wrote about how to convert Gregorian dates to Julian Day numbers or similar counts such as rata die as used in Calendrical Calculations . This algorithm is the core of C’s mktime() function that converts a broken-down date-time into linear time_t . I recently learned from Ben Joffe that I was missing a few tricks, and my old code wasn’t as good as it could have been. Here’s a…