committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 383 additions and 13 deletions
-
2src/common/CMakeLists.txt
-
49src/common/time_zone.cpp
-
18src/common/time_zone.h
-
11src/core/hle/service/time/time_manager.cpp
-
24src/core/hle/service/time/time_zone_content_manager.cpp
-
16src/core/settings.cpp
-
4src/core/settings.h
-
3src/yuzu/configuration/config.cpp
-
2src/yuzu/configuration/configure_system.cpp
-
1src/yuzu/configuration/configure_system.h
-
257src/yuzu/configuration/configure_system.ui
-
5src/yuzu_cmd/config.cpp
-
4src/yuzu_cmd/default_ini.h
@ -0,0 +1,49 @@ |
|||||
|
// Copyright 2020 yuzu Emulator Project
|
||||
|
// Licensed under GPLv2 or any later version
|
||||
|
// Refer to the license.txt file included.
|
||||
|
|
||||
|
#include <chrono>
|
||||
|
#include <iomanip>
|
||||
|
#include <sstream>
|
||||
|
|
||||
|
#include "common/logging/log.h"
|
||||
|
#include "common/time_zone.h"
|
||||
|
|
||||
|
namespace Common::TimeZone { |
||||
|
|
||||
|
std::string GetDefaultTimeZone() { |
||||
|
return "GMT"; |
||||
|
} |
||||
|
|
||||
|
static std::string GetOsTimeZoneOffset() { |
||||
|
const std::time_t t{std::time(nullptr)}; |
||||
|
const std::tm tm{*std::localtime(&t)}; |
||||
|
|
||||
|
std::stringstream ss; |
||||
|
ss << std::put_time(&tm, "%z"); // Get the current timezone offset, e.g. "-400", as a string
|
||||
|
|
||||
|
return ss.str(); |
||||
|
} |
||||
|
|
||||
|
static int ConvertOsTimeZoneOffsetToInt(const std::string& timezone) { |
||||
|
try { |
||||
|
return std::stoi(timezone); |
||||
|
} catch (const std::invalid_argument&) { |
||||
|
LOG_CRITICAL(Common, "invalid_argument with {}!", timezone); |
||||
|
return 0; |
||||
|
} catch (const std::out_of_range&) { |
||||
|
LOG_CRITICAL(Common, "out_of_range with {}!", timezone); |
||||
|
return 0; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
std::chrono::seconds GetCurrentOffsetSeconds() { |
||||
|
const int offset{ConvertOsTimeZoneOffsetToInt(GetOsTimeZoneOffset())}; |
||||
|
|
||||
|
int seconds{(offset / 100) * 60 * 60}; // Convert hour component to seconds
|
||||
|
seconds += (offset % 100) * 60; // Convert minute component to seconds
|
||||
|
|
||||
|
return std::chrono::seconds{seconds}; |
||||
|
} |
||||
|
|
||||
|
} // namespace Common::TimeZone
|
||||
@ -0,0 +1,18 @@ |
|||||
|
// Copyright 2020 yuzu Emulator Project |
||||
|
// Licensed under GPLv2 or any later version |
||||
|
// Refer to the license.txt file included. |
||||
|
|
||||
|
#pragma once |
||||
|
|
||||
|
#include <chrono> |
||||
|
#include <string> |
||||
|
|
||||
|
namespace Common::TimeZone { |
||||
|
|
||||
|
/// Gets the default timezone, i.e. "GMT" |
||||
|
std::string GetDefaultTimeZone(); |
||||
|
|
||||
|
/// Gets the offset of the current timezone (from the default), in seconds |
||||
|
std::chrono::seconds GetCurrentOffsetSeconds(); |
||||
|
|
||||
|
} // namespace Common::TimeZone |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue