コード例 #1
0
        public void All_Windows_Timezones_Should_Be_Convertable_To_Iana()
        {
            var allTimezones = TimezoneHelper.GetWindowsTimeZoneInfos();

            Should.NotThrow(() =>
            {
                var exceptions = new List <string>();

                foreach (var timezone in allTimezones)
                {
                    try
                    {
                        TimezoneHelper.WindowsToIana(timezone.Id);
                    }
                    catch (Exception ex)
                    {
                        exceptions.Add(ex.Message);
                    }
                }

                if (exceptions.Any())
                {
                    throw new Exception(exceptions.JoinAsString(Environment.NewLine));
                }
            });
        }
コード例 #2
0
 public List <NameValueDto> GetWindowsTimezones()
 {
     return(TimezoneHelper.GetWindowsTimeZoneInfos().OrderBy(tz => tz.BaseUtcOffset)
            .Select(tz => new NameValueDto
     {
         Value = tz.Id,
         Name = tz.DisplayName
     }).ToList());
 }