| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- using System;
- using IwbZero.Expr;
- using IwbZero.ToolCommon.StringModel;
- namespace IwbZero.ExprFunctions.Functions
- {
- /// <summary>
- /// 获取日期(年-月-01)
- /// </summary>
- public class FunGetFdm:IIwbFunction
- {
- public string Invoke(ExprObject exprObj)
- {
- DateTime now = DateTime.Now;
- int num = now.Year;
- now = DateTime.Now;
- int num2 = now.Month;
- ExprObject child = exprObj.GetChild(0);
- if (child != null)
- {
- ExprTypes exprTypes = EvalExpr.GetExprTypes(child);
- if (exprTypes == ExprTypes.Date || exprTypes == ExprTypes.String)
- {
- DateTime dateTime = child.Expr.StrToDt();
- num = dateTime.Year;
- num2 = dateTime.Month;
- }
- else
- {
- num = child.Expr.ValI();
- if (num == 0)
- {
- now = DateTime.Now;
- num = now.Year;
- }
- child = exprObj.GetChild(2);
- if (child != null)
- {
- num2 = child.Expr.ValI();
- }
- if (num2 == 0)
- {
- now = DateTime.Now;
- num2 = now.Month;
- }
- }
- }
- return $"{num}-{num2}-01";
- }
- }
- }
|