/// <summary>
 /// Calculates the offset from UTC of the specified date where date is of the time zone specified in dateTimeZone
 /// </summary>
 /// <param name="date"></param>
 /// <param name="dateTimeZone"></param>
 /// <returns></returns>
 public static TimeSpan GetUtcOffset(this DateTime date, SystemTimeZone dateTimeZone)
 {
     return(GetUtcOffset(date, dateTimeZone.ToString()));
 }
 public static int GetUtcOffsetInteger(this DateTime date, SystemTimeZone dateTimeZone)
 {
     return(GetUtcOffsetInteger(date, dateTimeZone.ToString()));
 }
 public static string LocalTimeToServerTime(this string localTime, SystemTimeZone serverTimeZone, string formatToReturn = "M/dd/yyyy h:mm tt")
 {
     return(DateTime.Parse(localTime).LocalTimeToServerTime(serverTimeZone).ToString(formatToReturn));
 }
 public static DateTime ToNewTimeZone(this DateTime @this, SystemTimeZone fromTimeZone, SystemTimeZone toTimeZone)
 {
     return(@this.ToNewTimeZone(fromTimeZone.ToString(), toTimeZone.ToString()));
 }
 public static DateTime LocalTimeToServerTime(this DateTime localTime, SystemTimeZone serverTimeZone)
 {
     return(LocalTimeToServerTime(localTime, serverTimeZone.ToString()));
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="serverTime"></param>
 /// <param name="localTimeZone"></param>
 /// <example>
 /// var localTimeZone = SystemTimeZone.DateLineStandardTime;
 /// var serverTime = DateTime.Now;
 /// var localTime = serverTime.ServerTimeToLocalTime(localTimeZone);</example>
 /// <returns></returns>
 public static DateTime ServerTimeToLocalTime(this DateTime serverTime, SystemTimeZone localTimeZone)
 {
     return(ServerTimeToLocalTime(serverTime, localTimeZone.ToString()));
 }
 public static DateTime?ToUniversalTime(this DateTime?localTime, SystemTimeZone localTimeZone)
 {
     return(localTime?.ToUniversalTime(localTimeZone.ToString()));
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="utcDate">The date time in UTC to convert to local.</param>
 /// <param name="localTimeZone">The time zone to convert to.</param>
 /// <returns></returns>
 public static DateTime?Local(this DateTime?utcDate, SystemTimeZone localTimeZone)
 {
     return(utcDate?.Local(localTimeZone));
 }
 public static DateTime Local(this DateTime utcDate, SystemTimeZone systemTimeZone)
 {
     return(Local(utcDate, systemTimeZone.ToString()));
 }