diff options
author | David Marcec <dmarcecguzman@gmail.com> | 2018-11-10 07:41:57 +0100 |
---|---|---|
committer | David Marcec <dmarcecguzman@gmail.com> | 2018-11-10 07:41:57 +0100 |
commit | ddc242dd516d6af58f16dc3fc089569d2eac093b (patch) | |
tree | 21f2c886bc0f7df2e3d6bbd333840b2681f86300 /src/core/hle | |
parent | Added consts and static (diff) | |
download | yuzu-ddc242dd516d6af58f16dc3fc089569d2eac093b.tar yuzu-ddc242dd516d6af58f16dc3fc089569d2eac093b.tar.gz yuzu-ddc242dd516d6af58f16dc3fc089569d2eac093b.tar.bz2 yuzu-ddc242dd516d6af58f16dc3fc089569d2eac093b.tar.lz yuzu-ddc242dd516d6af58f16dc3fc089569d2eac093b.tar.xz yuzu-ddc242dd516d6af58f16dc3fc089569d2eac093b.tar.zst yuzu-ddc242dd516d6af58f16dc3fc089569d2eac093b.zip |
Diffstat (limited to 'src/core/hle')
-rw-r--r-- | src/core/hle/service/time/time.cpp | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/src/core/hle/service/time/time.cpp b/src/core/hle/service/time/time.cpp index a3b3ffb8a..d312bd765 100644 --- a/src/core/hle/service/time/time.cpp +++ b/src/core/hle/service/time/time.cpp @@ -35,6 +35,20 @@ static void PosixToCalendar(u64 posix_time, CalendarTime& calendar_time, additional_info.utc_offset = 0; } +u64 CalendarToPosix(const CalendarTime& calendar_time, const TimeZoneRule& /*rule*/) { + std::tm time{}; + time.tm_year = calendar_time.year - 1900; + time.tm_mon = calendar_time.month - 1; + time.tm_mday = calendar_time.day; + + time.tm_hour = calendar_time.hour; + time.tm_min = calendar_time.minute; + time.tm_sec = calendar_time.second; + + std::time_t epoch_time = std::mktime(&time); + return static_cast<u64>(epoch_time); +} + class ISystemClock final : public ServiceFramework<ISystemClock> { public: ISystemClock() : ServiceFramework("ISystemClock") { @@ -100,8 +114,8 @@ public: {5, nullptr, "GetTimeZoneRuleVersion"}, {100, &ITimeZoneService::ToCalendarTime, "ToCalendarTime"}, {101, &ITimeZoneService::ToCalendarTimeWithMyRule, "ToCalendarTimeWithMyRule"}, - {201, nullptr, "ToPosixTime"}, - {202, nullptr, "ToPosixTimeWithMyRule"}, + {201, &ITimeZoneService::ToPosixTime, "ToPosixTime"}, + {202, &ITimeZoneService::ToPosixTimeWithMyRule, "ToPosixTimeWithMyRule"}, }; RegisterHandlers(functions); } @@ -170,6 +184,31 @@ private: rb.PushRaw(calendar_time); rb.PushRaw(additional_info); } + + void ToPosixTime(Kernel::HLERequestContext& ctx) { + // TODO(ogniK): Figure out how to handle multiple times + LOG_WARNING(Service_Time, "(STUBBED) called"); + IPC::RequestParser rp{ctx}; + auto calendar_time = rp.PopRaw<CalendarTime>(); + auto posix_time = CalendarToPosix(calendar_time, {}); + + IPC::ResponseBuilder rb{ctx, 3}; + rb.Push(RESULT_SUCCESS); + rb.PushRaw<u32>(1); // Amount of times we're returning + ctx.WriteBuffer(&posix_time, sizeof(u64)); + } + + void ToPosixTimeWithMyRule(Kernel::HLERequestContext& ctx) { + LOG_WARNING(Service_Time, "(STUBBED) called"); + IPC::RequestParser rp{ctx}; + auto calendar_time = rp.PopRaw<CalendarTime>(); + auto posix_time = CalendarToPosix(calendar_time, {}); + + IPC::ResponseBuilder rb{ctx, 3}; + rb.Push(RESULT_SUCCESS); + rb.PushRaw<u32>(1); // Amount of times we're returning + ctx.WriteBuffer(&posix_time, sizeof(u64)); + } }; void Module::Interface::GetStandardUserSystemClock(Kernel::HLERequestContext& ctx) { |