From 1dee9ec8dc0e4324b211f5f9c9176863de15d030 Mon Sep 17 00:00:00 2001 From: SimoneN64 Date: Sat, 1 Jul 2023 19:47:51 +0200 Subject: [PATCH 1/4] Add slash to CLion build folders' .gitignore line (makes it extra :sparkles: reliable :sparkles:) --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index de5ebd86..0f3828b9 100644 --- a/.gitignore +++ b/.gitignore @@ -8,7 +8,7 @@ #Clion Files .idea/ -cmake-build-* +cmake-build-*/ Debug/ Release/ From 117c6dfb97016b35d35f374b3ce39d49e6b53d10 Mon Sep 17 00:00:00 2001 From: wheremyfoodat <44909372+wheremyfoodat@users.noreply.github.com> Date: Sun, 2 Jul 2023 00:56:56 +0300 Subject: [PATCH 2/4] Make 3DS clock return system time and not UTC time --- src/core/memory.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/core/memory.cpp b/src/core/memory.cpp index 37c13c7d..9318c627 100644 --- a/src/core/memory.cpp +++ b/src/core/memory.cpp @@ -3,6 +3,7 @@ #include "resource_limits.hpp" #include #include // For time since epoch +#include using namespace KernelMemoryTypes; @@ -424,9 +425,19 @@ void Memory::mirrorMapping(u32 destAddress, u32 sourceAddress, u32 size) { u64 Memory::timeSince3DSEpoch() { using namespace std::chrono; - // ms since Jan 1 1970 - milliseconds ms = duration_cast(system_clock::now().time_since_epoch()); - // ms between Jan 1 1900 and Jan 1 1970 (2208988800 seconds elapsed between the two) + std::time_t rawTime = std::time(nullptr); // Get current UTC time + auto localTime = std::localtime(&rawTime); // Convert to local time + + bool daylightSavings = localTime->tm_isdst; // Get if time includes DST + localTime = std::gmtime(&rawTime); + + // Use gmtime + mktime to calculate difference between local time and UTC + auto timezoneDifference = rawTime - std::mktime(localTime); + if (daylightSavings) { + timezoneDifference += 60ull * 60ull; // Add 1 hour (60 seconds * 60 minutes) + } + + milliseconds ms = duration_cast(seconds(rawTime + timezoneDifference)); constexpr u64 offset = 2208988800ull * 1000; return ms.count() + offset; } \ No newline at end of file From 8930d44f5d1ed9a16178da39f4ede337ee4760b2 Mon Sep 17 00:00:00 2001 From: wheremyfoodat <44909372+wheremyfoodat@users.noreply.github.com> Date: Sun, 2 Jul 2023 01:00:57 +0300 Subject: [PATCH 3/4] Proper daylight savings time check --- src/core/memory.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/core/memory.cpp b/src/core/memory.cpp index 9318c627..dfa155a2 100644 --- a/src/core/memory.cpp +++ b/src/core/memory.cpp @@ -428,7 +428,7 @@ u64 Memory::timeSince3DSEpoch() { std::time_t rawTime = std::time(nullptr); // Get current UTC time auto localTime = std::localtime(&rawTime); // Convert to local time - bool daylightSavings = localTime->tm_isdst; // Get if time includes DST + bool daylightSavings = localTime->tm_isdst > 0; // Get if time includes DST localTime = std::gmtime(&rawTime); // Use gmtime + mktime to calculate difference between local time and UTC @@ -437,7 +437,8 @@ u64 Memory::timeSince3DSEpoch() { timezoneDifference += 60ull * 60ull; // Add 1 hour (60 seconds * 60 minutes) } - milliseconds ms = duration_cast(seconds(rawTime + timezoneDifference)); - constexpr u64 offset = 2208988800ull * 1000; - return ms.count() + offset; + // seconds between Jan 1 1900 and Jan 1 1970 + constexpr u64 offset = 2208988800ull; + milliseconds ms = duration_cast(seconds(rawTime + timezoneDifference + offset)); + return ms.count(); } \ No newline at end of file From cb251581847fadf642c2f36c218e64fd5005c146 Mon Sep 17 00:00:00 2001 From: wheremyfoodat <44909372+wheremyfoodat@users.noreply.github.com> Date: Sun, 2 Jul 2023 17:10:47 +0300 Subject: [PATCH 4/4] Stop downloading LLVM on MacOS CI --- .github/workflows/MacOS_Build.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/MacOS_Build.yml b/.github/workflows/MacOS_Build.yml index 819d4647..4007e0e9 100644 --- a/.github/workflows/MacOS_Build.yml +++ b/.github/workflows/MacOS_Build.yml @@ -23,13 +23,10 @@ jobs: - name: Fetch submodules run: git submodule update --init --recursive - - name: Install LLVM # MacOS comes with "AppleClang" instead of regular Clang, and it can't build the project because no proper C++20 - run: brew install llvm - - name: Configure CMake # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type - run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_C_COMPILER=/usr/local/opt/llvm/bin/clang -DCMAKE_CXX_COMPILER=/usr/local/opt/llvm/bin/clang++ + run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} - name: Build # Build your program with the given configuration