Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mipsel, 6.12.0.199] DateTime.Now fails: System.ArgumentOutOfRangeException: The TimeSpan parameter must be within plus or minus 14.0 hours. #21738

Open
devizer opened this issue Jan 22, 2024 · 0 comments

Comments

@devizer
Copy link

devizer commented Jan 22, 2024

Mono 6.12.0.199 is compiled from source tarball. csc works well. but any call to DateTime.Now fails with exception: System.ArgumentOutOfRangeException: The TimeSpan parameter must be within plus or minus 14.0 hours. The result doesn't depend on TZ env var (PST, UTC, etc)

DateTime.UtcNow works well.

Steps to Reproduce

Mono 6.12.0.199 is compiled from source tarball with default autogen.sh options on the mipsel host without any crosscompilers. libc 2.27, kernel 4.9, gcc 8.4.

Tests using bash:

TMPDIR="${TMPDIR:-/tmp}"
echo 'using System; using System.Diagnostics; class Program { static void Main() { Console.WriteLine($"Hello, World. Version {Environment.Version}. Working Set {Process.GetCurrentProcess().WorkingSet64:n0} bytes"); }  }' > "$TMPDIR/probe-hello.cs"
echo 'using System; using System.Diagnostics; class Program { static void Main() { Console.WriteLine($"UTC NOW: {DateTime.UtcNow}"); }  }' > "$TMPDIR/probe-utcnow.cs"
echo 'using System; using System.Diagnostics; class Program { static void Main() { Console.WriteLine($"NOW: {DateTime.Now}"); }  }' > "$TMPDIR/probe-now.cs"
for f in now hello utcnow; do
  echo ""; echo "PROBE $f"
  csc -nologo -out:"$TMPDIR/probe-$f.exe" "$TMPDIR/probe-$f.cs"
  mono "$TMPDIR/probe-$f.exe"
done

Output:

PROBE now
Unhandled Exception:
System.ArgumentOutOfRangeException: The TimeSpan parameter must be within plus or minus 14.0 hours.
Parameter name: baseUtcOffset
  at System.TimeZoneInfo.ValidateTimeZoneInfo (System.String id, System.TimeSpan baseUtcOffset, System.TimeZoneInfo+AdjustmentRule[] adjustmentRules, System.Boolean& adjustmentRulesSupportDst) [0x00034] in <a17d4f29e4f344d29b3db8a9764ba712>:0
  at System.TimeZoneInfo..ctor (System.String id, System.TimeSpan baseUtcOffset, System.String displayName, System.String standardDisplayName, System.String daylightDisplayName, System.TimeZoneInfo+AdjustmentRule[] adjustmentRules, System.Boolean disableDaylightSavingTime) [0x00006] in <a17d4f29e4f344d29b3db8a9764ba712>:0
  at System.TimeZoneInfo+CachedData.CreateLocal () [0x0001f] in <a17d4f29e4f344d29b3db8a9764ba712>:0
  at System.TimeZoneInfo+CachedData.get_Local () [0x0000c] in <a17d4f29e4f344d29b3db8a9764ba712>:0
  at System.TimeZoneInfo.get_Local () [0x00000] in <a17d4f29e4f344d29b3db8a9764ba712>:0
  at System.TimeZoneInfo.GetDateTimeNowUtcOffsetFromUtc (System.DateTime time, System.Boolean& isAmbiguousLocalDst) [0x00000] in <a17d4f29e4f344d29b3db8a9764ba712>:0
  at System.DateTime.get_Now () [0x00008] in <a17d4f29e4f344d29b3db8a9764ba712>:0
  at Program.Main () [0x00001] in <0ed61e189ff24567a594f9ba0c4c0650>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.ArgumentOutOfRangeException: The TimeSpan parameter must be within plus or minus 14.0 hours.
Parameter name: baseUtcOffset
  at System.TimeZoneInfo.ValidateTimeZoneInfo (System.String id, System.TimeSpan baseUtcOffset, System.TimeZoneInfo+AdjustmentRule[] adjustmentRules, System.Boolean& adjustmentRulesSupportDst) [0x00034] in <a17d4f29e4f344d29b3db8a9764ba712>:0
  at System.TimeZoneInfo..ctor (System.String id, System.TimeSpan baseUtcOffset, System.String displayName, System.String standardDisplayName, System.String daylightDisplayName, System.TimeZoneInfo+AdjustmentRule[] adjustmentRules, System.Boolean disableDaylightSavingTime) [0x00006] in <a17d4f29e4f344d29b3db8a9764ba712>:0
  at System.TimeZoneInfo+CachedData.CreateLocal () [0x0001f] in <a17d4f29e4f344d29b3db8a9764ba712>:0
  at System.TimeZoneInfo+CachedData.get_Local () [0x0000c] in <a17d4f29e4f344d29b3db8a9764ba712>:0
  at System.TimeZoneInfo.get_Local () [0x00000] in <a17d4f29e4f344d29b3db8a9764ba712>:0
  at System.TimeZoneInfo.GetDateTimeNowUtcOffsetFromUtc (System.DateTime time, System.Boolean& isAmbiguousLocalDst) [0x00000] in <a17d4f29e4f344d29b3db8a9764ba712>:0
  at System.DateTime.get_Now () [0x00008] in <a17d4f29e4f344d29b3db8a9764ba712>:0
  at Program.Main () [0x00001] in <0ed61e189ff24567a594f9ba0c4c0650>:0

PROBE hello
Hello, World. Version 4.0.30319.42000. Working Set 12,591,104 bytes

PROBE utcnow
UTC NOW: 01/22/2024 06:01:47

Current Behavior

Expected Behavior

On which platforms did you notice this

[ ] macOS
[x] Linux
[ ] Windows

Version Used:

6.12.0.199

Stacktrace

System.ArgumentOutOfRangeException: The TimeSpan parameter must be within plus or minus 14.0 hours.
Parameter name: baseUtcOffset
  at System.TimeZoneInfo.ValidateTimeZoneInfo (System.String id, System.TimeSpan baseUtcOffset, System.TimeZoneInfo+AdjustmentRule[] adjustmentRules, System.Boolean& adjustmentRulesSupportDst) [0x00034] in <a17d4f29e4f344d29b3db8a9764ba712>:0
  at System.TimeZoneInfo..ctor (System.String id, System.TimeSpan baseUtcOffset, System.String displayName, System.String standardDisplayName, System.String daylightDisplayName, System.TimeZoneInfo+AdjustmentRule[] adjustmentRules, System.Boolean disableDaylightSavingTime) [0x00006] in <a17d4f29e4f344d29b3db8a9764ba712>:0
  at System.TimeZoneInfo+CachedData.CreateLocal () [0x0001f] in <a17d4f29e4f344d29b3db8a9764ba712>:0
  at System.TimeZoneInfo+CachedData.get_Local () [0x0000c] in <a17d4f29e4f344d29b3db8a9764ba712>:0
  at System.TimeZoneInfo.get_Local () [0x00000] in <a17d4f29e4f344d29b3db8a9764ba712>:0
  at System.TimeZoneInfo.GetDateTimeNowUtcOffsetFromUtc (System.DateTime time, System.Boolean& isAmbiguousLocalDst) [0x00000] in <a17d4f29e4f344d29b3db8a9764ba712>:0
  at System.DateTime.get_Now () [0x00008] in <a17d4f29e4f344d29b3db8a9764ba712>:0
  at Program.Main () [0x00001] in <0ed61e189ff24567a594f9ba0c4c0650>:0```

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant