Skip to content
This repository has been archived by the owner on Mar 31, 2019. It is now read-only.

Commit

Permalink
Merge pull request #8 from DrLex0/day_offset_prefs_item
Browse files Browse the repository at this point in the history
Add prefs item "dayofs" for finer-grained time offset
  • Loading branch information
kanjitalk755 authored Feb 10, 2019
2 parents 0aa4e08 + 812dc28 commit 276814c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion SheepShaver/src/macos_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ uint32 TimeToMacTime(time_t t)
#endif
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"));
int a4 = ((local->tm_year + TM_EPOCH_YEAR) >> 2) - !(local->tm_year & 3);
int b4 = (MAC_EPOCH_YEAR >> 2) - !(MAC_EPOCH_YEAR & 3);
Expand All @@ -344,7 +345,10 @@ 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;
return local->tm_sec + 60 * (local->tm_min + 60 * (local->tm_hour + 24 * days));
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
1 change: 1 addition & 0 deletions SheepShaver/src/prefs_items.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ prefs_desc common_prefs_items[] = {
{"scale_integer",TYPE_BOOLEAN,false,"integer scaling"},
{"cpuclock", TYPE_INT32, 0, "CPU clock [MHz] of system info"},
{"yearofs", TYPE_INT32, 0, "year offset"},
{"dayofs", TYPE_INT32, 0, "day offset"},
{NULL, TYPE_END, false, NULL} // End of list
};

Expand Down

0 comments on commit 276814c

Please sign in to comment.