// 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); }
// ToPosixTimeWithMyRule(nn::time::CalendarTime calendarTime) -> (u32 outCount, buffer<nn::time::PosixTime, 0xa>) public ResultCode ToPosixTimeWithMyRule(ServiceCtx context) { CalendarTime calendarTime = context.RequestData.ReadStruct <CalendarTime>(); ResultCode resultCode = TimeZoneManager.Instance.ToPosixTimeWithMyRules(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); // There could be only one result on one calendar as leap seconds aren't supported. context.ResponseData.Write(1); } return(resultCode); }