summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar David Marcec2018-11-10 17:41:57 +1100
committerGravatar David Marcec2018-11-10 17:41:57 +1100
commitddc242dd516d6af58f16dc3fc089569d2eac093b (patch)
tree21f2c886bc0f7df2e3d6bbd333840b2681f86300
parentAdded consts and static (diff)
downloadyuzu-ddc242dd516d6af58f16dc3fc089569d2eac093b.tar.gz
yuzu-ddc242dd516d6af58f16dc3fc089569d2eac093b.tar.xz
yuzu-ddc242dd516d6af58f16dc3fc089569d2eac093b.zip
Added ToPosixTime & ToPosixTimeWithMyRule
Added instead of using a seperate PR to prevent conflicts
-rw-r--r--src/core/hle/service/time/time.cpp43
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,
35 additional_info.utc_offset = 0; 35 additional_info.utc_offset = 0;
36} 36}
37 37
38u64 CalendarToPosix(const CalendarTime& calendar_time, const TimeZoneRule& /*rule*/) {
39 std::tm time{};
40 time.tm_year = calendar_time.year - 1900;
41 time.tm_mon = calendar_time.month - 1;
42 time.tm_mday = calendar_time.day;
43
44 time.tm_hour = calendar_time.hour;
45 time.tm_min = calendar_time.minute;
46 time.tm_sec = calendar_time.second;
47
48 std::time_t epoch_time = std::mktime(&time);
49 return static_cast<u64>(epoch_time);
50}
51
38class ISystemClock final : public ServiceFramework<ISystemClock> { 52class ISystemClock final : public ServiceFramework<ISystemClock> {
39public: 53public:
40 ISystemClock() : ServiceFramework("ISystemClock") { 54 ISystemClock() : ServiceFramework("ISystemClock") {
@@ -100,8 +114,8 @@ public:
100 {5, nullptr, "GetTimeZoneRuleVersion"}, 114 {5, nullptr, "GetTimeZoneRuleVersion"},
101 {100, &ITimeZoneService::ToCalendarTime, "ToCalendarTime"}, 115 {100, &ITimeZoneService::ToCalendarTime, "ToCalendarTime"},
102 {101, &ITimeZoneService::ToCalendarTimeWithMyRule, "ToCalendarTimeWithMyRule"}, 116 {101, &ITimeZoneService::ToCalendarTimeWithMyRule, "ToCalendarTimeWithMyRule"},
103 {201, nullptr, "ToPosixTime"}, 117 {201, &ITimeZoneService::ToPosixTime, "ToPosixTime"},
104 {202, nullptr, "ToPosixTimeWithMyRule"}, 118 {202, &ITimeZoneService::ToPosixTimeWithMyRule, "ToPosixTimeWithMyRule"},
105 }; 119 };
106 RegisterHandlers(functions); 120 RegisterHandlers(functions);
107 } 121 }
@@ -170,6 +184,31 @@ private:
170 rb.PushRaw(calendar_time); 184 rb.PushRaw(calendar_time);
171 rb.PushRaw(additional_info); 185 rb.PushRaw(additional_info);
172 } 186 }
187
188 void ToPosixTime(Kernel::HLERequestContext& ctx) {
189 // TODO(ogniK): Figure out how to handle multiple times
190 LOG_WARNING(Service_Time, "(STUBBED) called");
191 IPC::RequestParser rp{ctx};
192 auto calendar_time = rp.PopRaw<CalendarTime>();
193 auto posix_time = CalendarToPosix(calendar_time, {});
194
195 IPC::ResponseBuilder rb{ctx, 3};
196 rb.Push(RESULT_SUCCESS);
197 rb.PushRaw<u32>(1); // Amount of times we're returning
198 ctx.WriteBuffer(&posix_time, sizeof(u64));
199 }
200
201 void ToPosixTimeWithMyRule(Kernel::HLERequestContext& ctx) {
202 LOG_WARNING(Service_Time, "(STUBBED) called");
203 IPC::RequestParser rp{ctx};
204 auto calendar_time = rp.PopRaw<CalendarTime>();
205 auto posix_time = CalendarToPosix(calendar_time, {});
206
207 IPC::ResponseBuilder rb{ctx, 3};
208 rb.Push(RESULT_SUCCESS);
209 rb.PushRaw<u32>(1); // Amount of times we're returning
210 ctx.WriteBuffer(&posix_time, sizeof(u64));
211 }
173}; 212};
174 213
175void Module::Interface::GetStandardUserSystemClock(Kernel::HLERequestContext& ctx) { 214void Module::Interface::GetStandardUserSystemClock(Kernel::HLERequestContext& ctx) {