Skip to content

Commit

Permalink
invert sign of yearofs and dayofs
Browse files Browse the repository at this point in the history
  • Loading branch information
kanjitalk755 committed Feb 10, 2019
1 parent 2eed2f0 commit dce4a95
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions BasiliskII/src/macos_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ uint32 TimeToMacTime(time_t t)
const int TM_EPOCH_YEAR = 1900;
const int MAC_EPOCH_YEAR = 1904;
// Clip year and day offsets to prevent dates earlier than 1-Jan-1904
local->tm_year = std::max(MAC_EPOCH_YEAR - TM_EPOCH_YEAR, local->tm_year - PrefsFindInt32("yearofs"));
local->tm_year = std::max(MAC_EPOCH_YEAR - TM_EPOCH_YEAR, local->tm_year + PrefsFindInt32("yearofs"));
int a4 = ((local->tm_year + TM_EPOCH_YEAR) >> 2) - !(local->tm_year & 3);
int b4 = (MAC_EPOCH_YEAR >> 2) - !(MAC_EPOCH_YEAR & 3);
int a100 = a4 / 25 - (a4 % 25 < 0);
Expand All @@ -146,7 +146,7 @@ uint32 TimeToMacTime(time_t t)
int b400 = b100 >> 2;
int intervening_leap_days = (a4 - b4) - (a100 - b100) + (a400 - b400);
uint32 days = local->tm_yday + 365 * (local->tm_year - 4) + intervening_leap_days;
int32 dayofs = PrefsFindInt32("dayofs");
int32 dayofs = -PrefsFindInt32("dayofs");
if(dayofs > 0 && dayofs > days)
dayofs = days;
return local->tm_sec + 60 * (local->tm_min + 60 * (local->tm_hour + 24 * (days - dayofs)));
Expand Down
4 changes: 2 additions & 2 deletions SheepShaver/src/macos_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ uint32 TimeToMacTime(time_t t)
const int TM_EPOCH_YEAR = 1900;
const int MAC_EPOCH_YEAR = 1904;
// Clip year and day offsets to prevent dates earlier than 1-Jan-1904
local->tm_year = std::max(MAC_EPOCH_YEAR - TM_EPOCH_YEAR, local->tm_year - PrefsFindInt32("yearofs"));
local->tm_year = std::max(MAC_EPOCH_YEAR - TM_EPOCH_YEAR, local->tm_year + PrefsFindInt32("yearofs"));
int a4 = ((local->tm_year + TM_EPOCH_YEAR) >> 2) - !(local->tm_year & 3);
int b4 = (MAC_EPOCH_YEAR >> 2) - !(MAC_EPOCH_YEAR & 3);
int a100 = a4 / 25 - (a4 % 25 < 0);
Expand All @@ -345,7 +345,7 @@ uint32 TimeToMacTime(time_t t)
int b400 = b100 >> 2;
int intervening_leap_days = (a4 - b4) - (a100 - b100) + (a400 - b400);
uint32 days = local->tm_yday + 365 * (local->tm_year - 4) + intervening_leap_days;
int32 dayofs = PrefsFindInt32("dayofs");
int32 dayofs = -PrefsFindInt32("dayofs");
if(dayofs > 0 && dayofs > days)
dayofs = days;
return local->tm_sec + 60 * (local->tm_min + 60 * (local->tm_hour + 24 * (days - dayofs)));
Expand Down

0 comments on commit dce4a95

Please sign in to comment.