tags:

views:

255

answers:

2

I have a piece of code in ANSI C which uses the time.h library and time_h structures to (amongst other date-related calculations) work out the interval between two given dates. This works fine but this limits my code to input between 1970 and 2038. I would now like to make my code more general.

Is there a common C library (ANSI or C99 standard) which implements date calculations on ranges larger than time.h, on a granularity of 1 day (i.e. I need to-the-day resolution but hour resolution is not necessary)?

(I'm adapting the code to deal with historical events hence it would be nice if it could also deal with dates in B.C. ....)

+1  A: 

There's a public domain implementation used in SQLite: documentation, source

I've also found the Calendar FAQ useful; this page pops up early on Google.

Doug Currie
+2  A: 

Yes, the y2038 project is reimplementing time.h to be 2038 safe. So far gmtime(), localtime(), mktime() and gmtime() are done and well tested. Those were the hard bits. It spans about 300 billion years in either direction.

Schwern