summaryrefslogtreecommitdiff
path: root/zen/time.h
diff options
context:
space:
mode:
authorB. Stack <bgstack15@gmail.com>2021-06-12 16:51:25 +0000
committerB. Stack <bgstack15@gmail.com>2021-06-12 16:51:25 +0000
commitd22ca0d17503de5733c909764cd54b586b52134f (patch)
treeb8076aea9d6e6408500ea8925ff233c2159a220b /zen/time.h
parentMerge branch '11.10' into 'master' (diff)
parentadd upstream 11.11 (diff)
downloadFreeFileSync-d22ca0d17503de5733c909764cd54b586b52134f.tar.gz
FreeFileSync-d22ca0d17503de5733c909764cd54b586b52134f.tar.bz2
FreeFileSync-d22ca0d17503de5733c909764cd54b586b52134f.zip
Merge branch '11.11' into 'master'11.11
add upstream 11.11 See merge request opensource-tracking/FreeFileSync!34
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