Exemplo n.º 1
0
 public static DateTimeOffset?StringToNullableDateTimeOffset(string str)
 {
     if (StringDateTimeOffsetDeterminer.Is(str))
     {
         return(StringDateTimeOffsetDeterminer.To(str));
     }
     if (DateTimeOffset.TryParse(str, out var dateTimeOffset))
     {
         return(dateTimeOffset);
     }
     return(null);
 }
Exemplo n.º 2
0
 public static DateTimeOffset ObjectToDateTimeOffset(object obj, DateTimeOffset defaultVal = default)
 {
     if (obj is null)
     {
         return(defaultVal);
     }
     if (obj is string str)
     {
         return(StringToDateTimeOffset(str, defaultVal));
     }
     str = obj.ToString();
     if (StringDateTimeOffsetDeterminer.Is(str))
     {
         return(StringToDateTimeOffset(str, defaultVal));
     }
     return(DateTimeOffset.TryParse(str, out var dateTimeOffset) ? dateTimeOffset : defaultVal);
 }
 /// <summary>
 /// Is DateTimeOffset
 /// </summary>
 /// <param name="str"></param>
 /// <returns></returns>
 public static bool IsDateTimeOffset(this string str) => StringDateTimeOffsetDeterminer.Is(str);
Exemplo n.º 4
0
 public static bool __dateTimeOffsetIs(string s, Type type, Action <object> action, string format, DateTimeStyles?dateTimeStyle, IFormatProvider provider) =>
 type == TypeClass.DateTimeOffsetClazz && (format is null
         ? StringDateTimeOffsetDeterminer.Is(s, dateTimeStyle ?? DateTimeStyles.None, provider, ValueConverter.ConvertAct <DateTimeOffset>(action))
         : StringDateTimeOffsetDeterminer.Exact.Is(s, format, dateTimeStyle ?? DateTimeStyles.None, provider, ValueConverter.ConvertAct <DateTimeOffset>(action)));