src/fursvp.helpers/DateTimeExtensions.cs
/// <summary>
/// Converts a DateTime from utc time to a local time zone.
/// </summary>
/// <param name="utcDateTime">The utc datetime.</param>
/// <param name="targetTimeZoneId">The local time zone to which to convert from utc time.</param>
/// <param name="localDateTime">The local datetime result, or the utc datetime if conversion was unsuccessful.</param>
/// <returns>A value indicating whether the conversion was successful.</returns>
Converts a DateTime from utc time to a local time zone.
Converts a DateTime from utc time to a local time zone .
public static bool TryToLocal(this DateTime utcDateTime, string targetTimeZoneId, out DateTime localDateTime)
        {
            try
            {
                localDateTime = utcDateTime.ToLocal(targetTimeZoneId);
                return true;
            }
            catch
            {
                localDateTime = utcDateTime;
                return false;
            }
        }
public static bool TryToLocal ( this DateTime utcDateTime , string targetTimeZoneId , out DateTime localDateTime ) { try { localDateTime = utcDateTime . ToLocal ( targetTimeZoneId ) ; return true ; } catch { localDateTime = utcDateTime ; return false ; } }
Converts a DateTime from utc time to a local time zone.
Converts a DateTime from utc time to a local time zone .
A value indicating whether the conversion was successful.
A value indicating whether the conversion was successful .
DateTime
out
targetTimeZoneId
string
The local time zone to which to convert from utc time.
The local time zone to which to convert from utc time .
utcDateTime
The utc datetime.
The utc datetime .
localDateTime
The local datetime result, or the utc datetime if conversion was unsuccessful.
The local datetime result or the utc datetime if conversion was unsuccessful .