mirror of
				https://github.com/PabloMK7/citra.git
				synced 2025-10-31 13:50:03 +00:00 
			
		
		
		
	feat: add system time offset setting (#6139)
* Add setting for system time offset Add a setting to displace citra system time by days, hours, minutes or seconds Add UI for the setting which is only visible when clock is set to system time Change core/settings.h to include the setting * Add system time offset to kernel Actually makes use of the time offset. * Fix time offset calculatioon in core/movie.cpp * Replace C++20 chrono::days with seconds Hopefully fixes the build.
This commit is contained in:
		
							parent
							
								
									3b6ffd9c27
								
							
						
					
					
						commit
						64062162c6
					
				
					 7 changed files with 138 additions and 11 deletions
				
			
		|  | @ -45,6 +45,16 @@ static std::chrono::seconds GetInitTime() { | |||
|         std::tm* now_tm = std::localtime(&now_time_t); | ||||
|         if (now_tm && now_tm->tm_isdst > 0) | ||||
|             now = now + std::chrono::hours(1); | ||||
| 
 | ||||
|         // add the offset
 | ||||
|         s64 init_time_offset = Settings::values.init_time_offset; | ||||
|         long long days_offset = init_time_offset / 86400; | ||||
|         long long days_offset_in_seconds = days_offset * 86400; // h/m/s truncated
 | ||||
|         unsigned long long seconds_offset = | ||||
|             std::abs(init_time_offset) - std::abs(days_offset_in_seconds); | ||||
| 
 | ||||
|         now = now + std::chrono::seconds(seconds_offset); | ||||
|         now = now + std::chrono::seconds(days_offset_in_seconds); | ||||
|         return std::chrono::duration_cast<std::chrono::seconds>(now.time_since_epoch()); | ||||
|     } | ||||
|     case Settings::InitClock::FixedTime: | ||||
|  |  | |||
|  | @ -601,9 +601,17 @@ void Movie::PrepareForPlayback(const std::string& movie_file) { | |||
| } | ||||
| 
 | ||||
| void Movie::PrepareForRecording() { | ||||
|     init_time = (Settings::values.init_clock == Settings::InitClock::SystemTime | ||||
|                      ? Common::Timer::GetTimeSinceJan1970().count() | ||||
|                      : Settings::values.init_time); | ||||
|     if (Settings::values.init_clock == Settings::InitClock::SystemTime) { | ||||
|         long long init_time_offset = Settings::values.init_time_offset; | ||||
|         long long days_offset = init_time_offset / 86400; | ||||
|         unsigned long long seconds_offset = | ||||
|             std::abs(init_time_offset) - std::abs(days_offset * 86400); | ||||
| 
 | ||||
|         init_time = | ||||
|             Common::Timer::GetTimeSinceJan1970().count() + seconds_offset + (days_offset * 86400); | ||||
|     } else { | ||||
|         init_time = Settings::values.init_time; | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| Movie::ValidationResult Movie::ValidateMovie(const std::string& movie_file) const { | ||||
|  |  | |||
|  | @ -163,6 +163,7 @@ struct Values { | |||
|     int region_value; | ||||
|     InitClock init_clock; | ||||
|     u64 init_time; | ||||
|     s64 init_time_offset; | ||||
| 
 | ||||
|     // Renderer
 | ||||
|     bool use_gles; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue