FunGetFdy.cs 931 B

12345678910111213141516171819202122232425262728293031323334
  1. using System;
  2. using IwbZero.Expr;
  3. using IwbZero.ToolCommon.StringModel;
  4. namespace IwbZero.ExprFunctions.Functions
  5. {
  6. /// <summary>
  7. /// 获取日期(年-01-01)
  8. /// </summary>
  9. public class FunGetFdy:IIwbFunction
  10. {
  11. public string Invoke(ExprObject exprObj)
  12. {
  13. DateTime dateTime = DateTime.Now;
  14. int num = dateTime.Year;
  15. ExprObject child = exprObj.GetChild(0);
  16. if (child != null)
  17. {
  18. ExprTypes exprTypes = EvalExpr.GetExprTypes(child);
  19. if (exprTypes == ExprTypes.Integer || exprTypes == ExprTypes.Decimal)
  20. {
  21. num = child.Expr.ValI();
  22. }
  23. else
  24. {
  25. dateTime = child.Expr.StrToDt();
  26. num = dateTime.Year;
  27. }
  28. }
  29. return $"{num}-01-01";
  30. }
  31. }
  32. }