mirror of
https://github.com/par274/sharpemu.git
synced 2026-07-31 23:19:44 +08:00
Fix sceRtcConvertLocalTimeToUtc failing on non-UTC hosts (#210)
The guest local tick was decoded into a DateTimeKind.Utc DateTime and then passed to TimeZoneInfo.ConvertTimeToUtc together with TimeZoneInfo.Local. That overload throws ArgumentException when a Utc-kind value is paired with a source zone other than UTC, so on any machine whose local zone is not UTC the export caught the exception and always returned INVALID_ARGUMENT. Re-tag the decoded value as DateTimeKind.Unspecified so it is interpreted as local wall-clock time and converted correctly. The reverse direction (sceRtcConvertUtcToLocalTime) was already correct because ConvertTimeFromUtc accepts a Utc-kind input. Add a RtcExports unit-test suite covering the tick/calendar conversions, DOS time packing, Win32 file time, leap-year and validation error codes, and a regression test that round-trips a UTC tick through local time and back.
This commit is contained in:
@@ -84,6 +84,12 @@ public static class RtcExports
|
||||
return (int)OrbisGen2Result.ORBIS_GEN2_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
// TryConvertTickToDateTime yields a Utc-kind DateTime, but here the tick is a local
|
||||
// wall-clock time. ConvertTimeToUtc throws ArgumentException when a Utc-kind value is
|
||||
// paired with a non-UTC source zone, so on any host not set to UTC this would always
|
||||
// fail. Re-tag as Unspecified so the value is interpreted as local time and converted.
|
||||
localDateTime = DateTime.SpecifyKind(localDateTime, DateTimeKind.Unspecified);
|
||||
|
||||
DateTime utcDateTime;
|
||||
try
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user