Пример #1
0
        public static string ToLocalStr(TimeZoneUtil tz, DateTime dtUtc, IFormatProvider culture, string format = null)
        {
            // Localize the time string for user display.
            // if tz == null then just label as (UTC) clearly.

            var tzi = tz?.GetTimeZoneInfo();

            if (tzi == null)
            {
                // Just label as UTC or (LOCAL)
                return(dtUtc.ToDtString(format, culture) + "(UTC)");
            }

            return(TimeZoneInfo.ConvertTimeFromUtc(dtUtc, tzi).ToDtString(format, culture));
        }