コード例 #1
0
 /// <summary>
 /// Converts the local time of the source time-zone to the local time of the
 /// destination time-zone.
 /// </summary>
 /// <param name="source">The source time-zone</param>
 /// <param name="destination">The destination time-zone</param>
 /// <param name="sourceLocalTime">The local time of the source time-zone that is
 /// to be converted to the local time in the destination time-zone</param>
 /// <returns>The local time in the destination time-zone.</returns>
 public static DateTime Convert(TimeZoneInfo source, TimeZoneInfo destination,
                                DateTime sourceLocalTime)
 {
     //since we now have the UtcTime, we can forward the call to the ConvertUtcTimeZone
     //method and return that functions return value
     return(TimeZoneInfo.ToLocalTime(destination,
                                     TimeZoneInfo.ToUniversalTime(source, sourceLocalTime)));
 }
コード例 #2
0
 /// <summary>
 /// Converts a local time of this time-zone to a Utc time
 /// </summary>
 /// <param name="localTime">The local time in the source time-zone</param>
 /// <returns>The Utc time that is equivalent to the local time in the source time-zone.</returns>
 public DateTime ToUniversalTime(DateTime localTime)
 {
     return(TimeZoneInfo.ToUniversalTime(this, localTime));
 }