Beispiel #1
0
        public static DateTime ConvertFromUtc(DateTime utcDateTime, int timeZoneId)
        {
            var kindCorrected = DateTime.SpecifyKind(utcDateTime, DateTimeKind.Utc);
            var tenantZone    =                                                                                                                              //54 here got from dbo.Tenants->TimeZoneId
                                DateTimeZoneProviders.Tzdb.GetZoneOrNull(SystemTimezoneOptionInfo.GetOrDefault((SystemTimezoneOption)timeZoneId).OlsonName); //"Etc/UTC";//_tenantSettings.Info.Timezone;

            return(Instant.FromDateTimeUtc(kindCorrected).InZone(tenantZone).ToDateTimeUnspecified());
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            decimal x = 10.4M;

            Console.WriteLine(x.ToString("N2"));
            var timeZone =
                DateTimeZoneProviders.Tzdb.GetZoneOrNull(
                    SystemTimezoneOptionInfo.GetOrDefault(SystemTimezoneOption.America_Chicago).OlsonName);

            Console.WriteLine(ConvertFromUtc(DateTime.UtcNow, timeZone));
        }