/// <summary>
 /// To nullable TimeSpan
 /// </summary>
 /// <param name="str"></param>
 /// <returns></returns>
 public static DateTimeSpan?CastToNullableDateTimeSpan(this string str)
 {
     if (StringDateTimeSpanDeterminer.Is(str))
     {
         return(CastToDateTimeSpan(str));
     }
     return(null);
 }
 /// <summary>
 /// To DateTimeSpan
 /// </summary>
 /// <param name="str"></param>
 /// <param name="defaultVal"></param>
 /// <returns></returns>
 public static DateTimeSpan CastToDateTimeSpan(this string str, DateTimeSpan defaultVal = default)
 => StringDateTimeSpanDeterminer.To(str, defaultVal: defaultVal);
Exemple #3
0
 /// <summary>
 /// Convert the given string to a nullable <see cref="DateTimeSpan"/>. <br />
 /// 将给定的字符串转换为可空的 <see cref="DateTimeSpan"/>。
 /// </summary>
 /// <param name="str"></param>
 /// <returns></returns>
 public static DateTimeSpan?CastToNullableDateTimeSpan(this string str)
 {
     return(StringDateTimeSpanDeterminer.Is(str)
         ? CastToDateTimeSpan(str)
         : (DateTimeSpan?)null);
 }