diff options
Diffstat (limited to 'zen/time.h')
-rw-r--r-- | zen/time.h | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -159,11 +159,23 @@ TimeComp getUtcTime2(time_t utc) { //1. convert: seconds since year 1: //... + //assert(time_t is signed) //TODO: what if < 0? long long remDays = utc / (24 * 3600); long long remSecs = utc % (24 * 3600); + //days per year + const int dpYearStd = 365; + const int dpYearLeap = dpYearStd + 1; + const int dp4Years = 3 * dpYearStd + dpYearLeap; + const int dp100YearsStd = 25 * dp4Years - 1; //no leap days for centuries... + const int dp100YearsExc = 25 * dp4Years; //...except if divisible by 400 + const int dp400Years = 3 * dp100YearsStd + dp100YearsExc; + + + + const int daysPer4Years = 4 * 365 /*usual days per year*/ + 1 /*including leap day*/; const int daysPerYear = 365; //non-leap const int daysPer100Years = 25 * daysPer4Years - 1; @@ -197,6 +209,8 @@ TimeComp getUtcTime2(time_t utc) + const char daysPerMonth[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; + //first four years of century: |