@@ -420,6 +420,12 @@ public static Operand CreateNull()
420420 /// <param name="errorMessage"></param>
421421 /// <returns></returns>
422422 public virtual Operand ToMyDate ( string errorMessage = null ) { return Error ( errorMessage ) ; }
423+ /// <summary>
424+ /// 转MyDate类型
425+ /// </summary>
426+ /// <param name="errorMessage"></param>
427+ /// <returns></returns>
428+ public virtual Operand ToMyDate ( string errorMessage , int index ) { return Error ( string . Format ( errorMessage , index ) ) ; }
423429
424430 /// <summary>
425431 /// 转Json类型
@@ -631,6 +637,7 @@ public OperandNumber(decimal obj) : base(obj)
631637 public override Operand ToText ( string errorMessage , int index ) { return Create ( NumberValue . ToString ( CultureInfo . InvariantCulture ) ) ; }
632638
633639 public override Operand ToMyDate ( string errorMessage = null ) { return Create ( ( MyDate ) NumberValue ) ; }
640+ public override Operand ToMyDate ( string errorMessage , int index ) { return Create ( ( MyDate ) NumberValue ) ; }
634641
635642 public override Operand ToArray ( string errorMessage = null ) { return Error ( errorMessage ?? "Convert number to array error!" ) ; }
636643
@@ -733,6 +740,15 @@ public override Operand ToMyDate(string errorMessage = null)
733740 }
734741 return Error ( errorMessage ) ;
735742 }
743+ public override Operand ToMyDate ( string errorMessage , int index )
744+ {
745+ if ( TimeSpan . TryParse ( TextValue , CultureInfo . InvariantCulture , out TimeSpan t ) ) { return Create ( new MyDate ( t ) ) ; }
746+ if ( DateTime . TryParse ( TextValue , CultureInfo . InvariantCulture , DateTimeStyles . None , out DateTime d ) ) { return Create ( new MyDate ( d ) ) ; }
747+ if ( errorMessage == null ) {
748+ return Error ( "Convert string to date error!" ) ;
749+ }
750+ return Error ( string . Format ( errorMessage , index ) ) ;
751+ }
736752
737753 public override Operand ToJson ( string errorMessage = null )
738754 {
@@ -780,6 +796,7 @@ public OperandMyDate(MyDate obj) : base(obj)
780796 public override Operand ToText ( string errorMessage , int index ) { return Create ( DateValue . ToString ( ) ) ; }
781797
782798 public override Operand ToMyDate ( string errorMessage = null ) { return this ; }
799+ public override Operand ToMyDate ( string errorMessage , int index ) { return this ; }
783800
784801 public override Operand ToArray ( string errorMessage = null ) { return Error ( errorMessage ?? "Convert date to array error!" ) ; }
785802
@@ -880,6 +897,7 @@ public OperandError(string msg)
880897 public override Operand ToJson ( string errorMessage = null ) { return this ; }
881898
882899 public override Operand ToMyDate ( string errorMessage = null ) { return this ; }
900+ public override Operand ToMyDate ( string errorMessage , int index ) { return this ; }
883901 }
884902
885903 internal sealed class OperandNull : Operand
0 commit comments