Exemple #1
0
 public static TIME AsTIME(this DateTime value, TimeZoneInfo tzinfo)
 {
     if (value == default(DateTime)) return new TIME(default(TIME), tzinfo != null ? tzinfo.AsTZID() : null);
     if (tzinfo != null)
     {
         if (value.Kind == DateTimeKind.Utc) throw new ArgumentException();
         return new TIME((uint)value.Hour, (uint)value.Minute, (uint)value.Second, TimeType.LocalAndTimeZone);
     }
     return value.Kind == DateTimeKind.Utc 
         ? new TIME((uint)value.Hour, (uint)value.Minute, (uint)value.Second, TimeType.Utc) 
         : new TIME((uint)value.Hour, (uint)value.Minute, (uint)value.Second);
 }
Exemple #2
0
 public static TIME AsTIME(this TimeSpan span, TimeZoneInfo tzinfo = null, TimeType format = TimeType.NONE)
 {
     if (tzinfo != null)
     {
         if (format == TimeType.Utc) throw new ArgumentException();
         return format == TimeType.LocalAndTimeZone 
             ? new TIME((uint)span.Hours, (uint)span.Minutes, (uint)span.Seconds, format, tzinfo.AsTZID()) 
             : new TIME((uint)span.Hours, (uint)span.Minutes, (uint)span.Seconds);
     }
     return format == TimeType.Utc 
         ? new TIME((uint)span.Hours, (uint)span.Minutes, (uint)span.Seconds, format) 
         : new TIME((uint)span.Hours, (uint)span.Minutes, (uint)span.Seconds);
 }