3

I'm trying to create a synthetic timezone GMT+20 in Windows 10 (to test our software for extreme client-server TZ difference scenarios):

$standardDisplayName = "(GMT+20:00) Synthetic 20"
$standardName = "My Time"
$baseUtcOffset = New-TimeSpan -Hours 20
$daylightDisplayName=[string]::Empty
$adjustmentRules=$null
$disableDaylightSavingTime=$false

$newTZ = [TimeZoneInfo]::CreateCustomTimeZone($standardName, $baseUtcOffset, $standardDisplayName, $standardName,$daylightDisplayName,$adjustmentRules,$disableDaylightSavingTime)

And i'm getting

"The TimeSpan parameter must be within plus or minus 14.0 hours."

Is there any way around this?

  • 1
    What are you trying to test here? Plenty of bizarreness in TZ already, from offsets above +12, to fractional hour offsets, and both for Pacific/Chatham https://www.timeanddate.com/time/time-zones-interesting.html – John Mahowald Oct 16 '20 at 17:14
  • Mostly to have machines with a technically correct time (where UTC time and date would be correct), but at the same time having local date already be +1. For example, our server is in TZ +2, client machine is set to TZ +14, so, when server has 25 Oct 2020 12:01:00 (1 minute past midday), client has 26 Oct 2020 00:00:01 (1 minute past midnight next day) and we can commence testing of corner cases. If we had a TZ +20 - our testers would not have to wait till midday, instead could start testing such cases right after 06:00 in the morning (working from home some of them start very early). – Ivan Koshelev Oct 17 '20 at 19:38

1 Answers1

6

It is impossible with .NET method TimeZoneInfo.CreateCustomTimeZone , as BaseUtcOffset property should have value between 14 and - 14.

Prove: https://docs.microsoft.com/en-us/dotnet/api/system.timezoneinfo.baseutcoffset?view=net-5.0

batistuta09
  • 8,723
  • 9
  • 21