|
|
@ -3,6 +3,7 @@ |
|
|
// Refer to the license.txt file included.
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
|
#include <chrono>
|
|
|
#include <chrono>
|
|
|
|
|
|
#include <ctime>
|
|
|
#include "common/logging/log.h"
|
|
|
#include "common/logging/log.h"
|
|
|
#include "core/core_timing.h"
|
|
|
#include "core/core_timing.h"
|
|
|
#include "core/hle/ipc_helpers.h"
|
|
|
#include "core/hle/ipc_helpers.h"
|
|
|
@ -77,7 +78,7 @@ public: |
|
|
{3, nullptr, "LoadLocationNameList"}, |
|
|
{3, nullptr, "LoadLocationNameList"}, |
|
|
{4, &ITimeZoneService::LoadTimeZoneRule, "LoadTimeZoneRule"}, |
|
|
{4, &ITimeZoneService::LoadTimeZoneRule, "LoadTimeZoneRule"}, |
|
|
{5, nullptr, "GetTimeZoneRuleVersion"}, |
|
|
{5, nullptr, "GetTimeZoneRuleVersion"}, |
|
|
{100, nullptr, "ToCalendarTime"}, |
|
|
|
|
|
|
|
|
{100, &ITimeZoneService::ToCalendarTime, "ToCalendarTime"}, |
|
|
{101, &ITimeZoneService::ToCalendarTimeWithMyRule, "ToCalendarTimeWithMyRule"}, |
|
|
{101, &ITimeZoneService::ToCalendarTimeWithMyRule, "ToCalendarTimeWithMyRule"}, |
|
|
{200, nullptr, "ToPosixTime"}, |
|
|
{200, nullptr, "ToPosixTime"}, |
|
|
{201, nullptr, "ToPosixTimeWithMyRule"}, |
|
|
{201, nullptr, "ToPosixTimeWithMyRule"}, |
|
|
@ -86,9 +87,11 @@ public: |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private: |
|
|
private: |
|
|
|
|
|
LocationName location_name{"UTC"}; |
|
|
|
|
|
TimeZoneRule my_time_zone_rule{}; |
|
|
|
|
|
|
|
|
void GetDeviceLocationName(Kernel::HLERequestContext& ctx) { |
|
|
void GetDeviceLocationName(Kernel::HLERequestContext& ctx) { |
|
|
NGLOG_WARNING(Service_Time, "(STUBBED) called"); |
|
|
|
|
|
LocationName location_name{}; |
|
|
|
|
|
|
|
|
NGLOG_DEBUG(Service_Time, "called"); |
|
|
IPC::ResponseBuilder rb{ctx, (sizeof(LocationName) / 4) + 2}; |
|
|
IPC::ResponseBuilder rb{ctx, (sizeof(LocationName) / 4) + 2}; |
|
|
rb.Push(RESULT_SUCCESS); |
|
|
rb.Push(RESULT_SUCCESS); |
|
|
rb.PushRaw(location_name); |
|
|
rb.PushRaw(location_name); |
|
|
@ -103,23 +106,70 @@ private: |
|
|
|
|
|
|
|
|
void LoadTimeZoneRule(Kernel::HLERequestContext& ctx) { |
|
|
void LoadTimeZoneRule(Kernel::HLERequestContext& ctx) { |
|
|
NGLOG_WARNING(Service_Time, "(STUBBED) called"); |
|
|
NGLOG_WARNING(Service_Time, "(STUBBED) called"); |
|
|
|
|
|
|
|
|
|
|
|
ctx.WriteBuffer(&my_time_zone_rule, sizeof(TimeZoneRule)); |
|
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2}; |
|
|
IPC::ResponseBuilder rb{ctx, 2}; |
|
|
rb.Push(RESULT_SUCCESS); |
|
|
rb.Push(RESULT_SUCCESS); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void ToCalendarTime(Kernel::HLERequestContext& ctx) { |
|
|
|
|
|
IPC::RequestParser rp{ctx}; |
|
|
|
|
|
const u64 posix_time = rp.Pop<u64>(); |
|
|
|
|
|
|
|
|
|
|
|
NGLOG_WARNING(Service_Time, "(STUBBED) called, posix_time=0x{:016X}", posix_time); |
|
|
|
|
|
|
|
|
|
|
|
TimeZoneRule time_zone_rule{}; |
|
|
|
|
|
auto buffer = ctx.ReadBuffer(); |
|
|
|
|
|
std::memcpy(&time_zone_rule, buffer.data(), buffer.size()); |
|
|
|
|
|
|
|
|
|
|
|
CalendarTime calendar_time{2018, 1, 1, 0, 0, 0}; |
|
|
|
|
|
CalendarAdditionalInfo additional_info{}; |
|
|
|
|
|
|
|
|
|
|
|
PosixToCalendar(posix_time, calendar_time, additional_info, time_zone_rule); |
|
|
|
|
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 10}; |
|
|
|
|
|
rb.Push(RESULT_SUCCESS); |
|
|
|
|
|
rb.PushRaw(calendar_time); |
|
|
|
|
|
rb.PushRaw(additional_info); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
void ToCalendarTimeWithMyRule(Kernel::HLERequestContext& ctx) { |
|
|
void ToCalendarTimeWithMyRule(Kernel::HLERequestContext& ctx) { |
|
|
IPC::RequestParser rp{ctx}; |
|
|
IPC::RequestParser rp{ctx}; |
|
|
u64 posix_time = rp.Pop<u64>(); |
|
|
|
|
|
|
|
|
const u64 posix_time = rp.Pop<u64>(); |
|
|
|
|
|
|
|
|
NGLOG_WARNING(Service_Time, "(STUBBED) called, posix_time=0x{:016X}", posix_time); |
|
|
NGLOG_WARNING(Service_Time, "(STUBBED) called, posix_time=0x{:016X}", posix_time); |
|
|
|
|
|
|
|
|
CalendarTime calendar_time{2018, 1, 1, 0, 0, 0}; |
|
|
CalendarTime calendar_time{2018, 1, 1, 0, 0, 0}; |
|
|
CalendarAdditionalInfo additional_info{}; |
|
|
CalendarAdditionalInfo additional_info{}; |
|
|
|
|
|
|
|
|
|
|
|
PosixToCalendar(posix_time, calendar_time, additional_info, my_time_zone_rule); |
|
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 10}; |
|
|
IPC::ResponseBuilder rb{ctx, 10}; |
|
|
rb.Push(RESULT_SUCCESS); |
|
|
rb.Push(RESULT_SUCCESS); |
|
|
rb.PushRaw(calendar_time); |
|
|
rb.PushRaw(calendar_time); |
|
|
rb.PushRaw(additional_info); |
|
|
rb.PushRaw(additional_info); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void PosixToCalendar(u64 posix_time, CalendarTime& calendar_time, |
|
|
|
|
|
CalendarAdditionalInfo& additional_info, const TimeZoneRule& /*rule*/) { |
|
|
|
|
|
std::time_t t(posix_time); |
|
|
|
|
|
std::tm* tm = std::localtime(&t); |
|
|
|
|
|
if (!tm) { |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
calendar_time.year = tm->tm_year + 1900; |
|
|
|
|
|
calendar_time.month = tm->tm_mon + 1; |
|
|
|
|
|
calendar_time.day = tm->tm_mday; |
|
|
|
|
|
calendar_time.hour = tm->tm_hour; |
|
|
|
|
|
calendar_time.minute = tm->tm_min; |
|
|
|
|
|
calendar_time.second = tm->tm_sec; |
|
|
|
|
|
|
|
|
|
|
|
additional_info.day_of_week = tm->tm_wday; |
|
|
|
|
|
additional_info.day_of_year = tm->tm_yday; |
|
|
|
|
|
std::memcpy(additional_info.name.data(), "UTC", sizeof("UTC")); |
|
|
|
|
|
additional_info.utc_offset = 0; |
|
|
|
|
|
} |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
void Module::Interface::GetStandardUserSystemClock(Kernel::HLERequestContext& ctx) { |
|
|
void Module::Interface::GetStandardUserSystemClock(Kernel::HLERequestContext& ctx) { |
|
|
|