skip to Main Content

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?

2

Answers


  1. Chosen as BEST ANSWER

    This works:

    using System;
    
    TimeZoneInfo ET;
        
    if (WebDriverSetup.OSInfo.IsWindows)
    {
        ET = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time");
    }
    else
    {
        ET = TimeZoneInfo.FindSystemTimeZoneById("US/Eastern");
    }
    
    AtataContext.GlobalConfiguration.UseTimeZone(ET);


  2. 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"));
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search