summaryrefslogtreecommitdiff
path: root/zen/time.h
diff options
context:
space:
mode:
authorB. Stack <bgstack15@gmail.com>2021-06-12 09:59:08 -0400
committerB. Stack <bgstack15@gmail.com>2021-06-12 09:59:23 -0400
commitfc71e66e5186fb75206290deca2b9a6cfbefa9ac (patch)
treeb8076aea9d6e6408500ea8925ff233c2159a220b /zen/time.h
parentMerge branch '11.10' into 'master' (diff)
downloadFreeFileSync-fc71e66e5186fb75206290deca2b9a6cfbefa9ac.tar.gz
FreeFileSync-fc71e66e5186fb75206290deca2b9a6cfbefa9ac.tar.bz2
FreeFileSync-fc71e66e5186fb75206290deca2b9a6cfbefa9ac.zip
add upstream 11.11
Diffstat (limited to 'zen/time.h')
-rw-r--r--zen/time.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/zen/time.h b/zen/time.h
index b3b903b6..9b5f670e 100644
--- a/zen/time.h
+++ b/zen/time.h
@@ -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:
bgstack15