// ToPosixTime(nn::time::CalendarTime calendarTime, buffer<nn::time::TimeZoneRule, 0x15> rules) -> (u32 outCount, buffer<nn::time::PosixTime, 0xa>) public ResultCode ToPosixTime(ServiceCtx context) { long inBufferPosition = context.Request.SendBuff[0].Position; long inBufferSize = context.Request.SendBuff[0].Size; CalendarTime calendarTime = context.RequestData.ReadStruct <CalendarTime>(); if (inBufferSize != 0x4000) { // TODO: find error code here Logger.PrintError(LogClass.ServiceTime, $"TimeZoneRule buffer size is 0x{inBufferSize:x} (expected 0x4000)"); throw new InvalidOperationException(); } TimeZoneRule rules = MemoryHelper.Read <TimeZoneRule>(context.Memory, inBufferPosition); ResultCode resultCode = TimeZoneManager.ToPosixTime(rules, calendarTime, out long posixTime); if (resultCode == 0) { long outBufferPosition = context.Request.RecvListBuff[0].Position; long outBufferSize = context.Request.RecvListBuff[0].Size; context.Memory.WriteInt64(outBufferPosition, posixTime); context.ResponseData.Write(1); } return(resultCode); }
// ToCalendarTime(nn::time::PosixTime time, buffer<nn::time::TimeZoneRule, 0x15> rules) -> (nn::time::CalendarTime, nn::time::sf::CalendarAdditionalInfo) public ResultCode ToCalendarTime(ServiceCtx context) { long posixTime = context.RequestData.ReadInt64(); long bufferPosition = context.Request.SendBuff[0].Position; long bufferSize = context.Request.SendBuff[0].Size; if (bufferSize != 0x4000) { // TODO: find error code here Logger.PrintError(LogClass.ServiceTime, $"TimeZoneRule buffer size is 0x{bufferSize:x} (expected 0x4000)"); throw new InvalidOperationException(); } TimeZoneRule rules = MemoryHelper.Read <TimeZoneRule>(context.Memory, bufferPosition); ResultCode resultCode = TimeZoneManager.ToCalendarTime(rules, posixTime, out CalendarInfo calendar); if (resultCode == 0) { context.ResponseData.WriteStruct(calendar); } return(resultCode); }