atata

Specifying non-local time zone in GlobalConfiguration fails on Linux


My tests will be running on a variety of machines/containers scattered all across the USA, so I would like them all to log their time in Eastern Time. If I do this:

AtataContext.GlobalConfiguration.UseTimeZone(System.TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time"))

All my logs generated by Windows machines work fine, but in linux (Debian 11) I get this:

  Error Message:
   OneTimeSetUp: System.TimeZoneNotFoundException : The time zone ID 'Eastern Standard Time' was not found on the local computer.
  ----> System.IO.FileNotFoundException : Could not find file '/usr/share/zoneinfo/Eastern Standard Time'.

Is there something else I need to do to get the time zone synced across all logs?


Solution

  • The previous answer is correct. You can find a time zone by different names depending on current OS. But in addition to that here is another solution.

    You can add TimeZoneConverter NuGet package to a project and use its TZConvert class to find a time zone by either Windows or Linux time zone ID.

    AtataContext.GlobalConfiguration.UseTimeZone(TZConvert.GetTimeZoneInfo("US/Eastern"));