internal static bool IsTimeMatch(string timeExp, DateTime tTime) { bool blnRet = false; string cmpSet = timeExp.Trim(new char[] { ' ', '[', ']', '(', ')' }); // > >= == < <= int nIndex = GlobalUtil.FindFirstNumber(cmpSet); if (nIndex == -1) { throw new InvalidOperationException("时间值规则定义错误,必须包含数字(以及比较符号> >= == < <=) !"); } string cmpStr = cmpSet.Substring(0, nIndex).Trim(); string cmpValue = cmpSet.Substring(nIndex).Trim(); if (cmpStr == ">") { blnRet = Convert.ToDateTime(cmpValue) > tTime; } else if (cmpStr == ">=") { blnRet = Convert.ToDateTime(cmpValue) >= tTime; } else if (cmpStr == "==") { blnRet = Convert.ToDateTime(cmpValue) == tTime; } else if (cmpStr == "<") { blnRet = Convert.ToDateTime(cmpValue) < tTime; } else if (cmpStr == "<=") { blnRet = Convert.ToDateTime(cmpValue) <= tTime; } return(blnRet); }