public DateType(string name, System.Type type, Net.Vpc.Upa.Types.Date min, Net.Vpc.Upa.Types.Date max, bool nullable) : base(name, type == null ? typeof(Net.Vpc.Upa.Types.Date) : type, 0, 0, nullable) { if (type != null && !type.Equals(typeof(Net.Vpc.Upa.Types.Date)) && !type.Equals(typeof(Net.Vpc.Upa.Types.Temporal)) && !type.Equals(typeof(Net.Vpc.Upa.Types.Date))) { throw new Net.Vpc.Upa.Exceptions.IllegalArgumentException("Invalid Temporal Type " + type); } this.min = min; this.max = max; SetDefaultNonNullValue(Convert(new Net.Vpc.Upa.Types.DateTime(0))); }
public virtual object Eval(Net.Vpc.Upa.EvalContext evalContext) { object[] arg = evalContext.GetArguments(); Net.Vpc.Upa.Expressions.DatePartType type = (Net.Vpc.Upa.Expressions.DatePartType)arg[0]; object count = (object)arg[1]; Net.Vpc.Upa.Types.Date date = (Net.Vpc.Upa.Types.Date)arg[2]; Net.Vpc.Upa.Types.Calendar instance = Net.Vpc.Upa.Types.Calendar.GetInstance(); instance.SetTime(date); int f = -1; switch (type) { case Net.Vpc.Upa.Expressions.DatePartType.DATE: { f = Net.Vpc.Upa.Types.Calendar.DATE; break; } case Net.Vpc.Upa.Expressions.DatePartType.DAY: { f = Net.Vpc.Upa.Types.Calendar.DATE; break; } case Net.Vpc.Upa.Expressions.DatePartType.DAYOFMONTH: { f = Net.Vpc.Upa.Types.Calendar.DAY_OF_MONTH; break; } case Net.Vpc.Upa.Expressions.DatePartType.DAYOFWEEK: { f = Net.Vpc.Upa.Types.Calendar.DAY_OF_WEEK; break; } case Net.Vpc.Upa.Expressions.DatePartType.DAYOFYEAR: { f = Net.Vpc.Upa.Types.Calendar.DAY_OF_YEAR; break; } case Net.Vpc.Upa.Expressions.DatePartType.HOUR: { f = Net.Vpc.Upa.Types.Calendar.HOUR; break; } case Net.Vpc.Upa.Expressions.DatePartType.MILLISECOND: { f = Net.Vpc.Upa.Types.Calendar.MILLISECOND; break; } case Net.Vpc.Upa.Expressions.DatePartType.MINUTE: { f = Net.Vpc.Upa.Types.Calendar.MINUTE; break; } case Net.Vpc.Upa.Expressions.DatePartType.SECOND: { f = Net.Vpc.Upa.Types.Calendar.SECOND; break; } case Net.Vpc.Upa.Expressions.DatePartType.MONTH: { f = Net.Vpc.Upa.Types.Calendar.MONTH; break; } case Net.Vpc.Upa.Expressions.DatePartType.WEEK: { f = Net.Vpc.Upa.Types.Calendar.WEEK_OF_MONTH; break; } case Net.Vpc.Upa.Expressions.DatePartType.YEAR: { f = Net.Vpc.Upa.Types.Calendar.YEAR; break; } default: { throw new System.Exception("Unsupported"); } } instance.Add(f, System.Convert.ToInt32(count)); return(instance.GetTime()); }
public virtual object Eval(Net.Vpc.Upa.EvalContext evalContext) { object[] arg = evalContext.GetArguments(); Net.Vpc.Upa.Expressions.DatePartType type = (Net.Vpc.Upa.Expressions.DatePartType)arg[0]; object count = (object)arg[1]; Net.Vpc.Upa.Types.Date date = (Net.Vpc.Upa.Types.Date)arg[2]; Net.Vpc.Upa.Types.Calendar instance = Net.Vpc.Upa.Types.Calendar.GetInstance(); instance.SetTime(date); int f = -1; switch (type) { case Net.Vpc.Upa.Expressions.DatePartType.DATE: { f = Net.Vpc.Upa.Types.Calendar.DATE; break; } case Net.Vpc.Upa.Expressions.DatePartType.DAY: { f = Net.Vpc.Upa.Types.Calendar.DATE; break; } case Net.Vpc.Upa.Expressions.DatePartType.DAYOFMONTH: { f = Net.Vpc.Upa.Types.Calendar.DAY_OF_MONTH; break; } case Net.Vpc.Upa.Expressions.DatePartType.DAYOFWEEK: { f = Net.Vpc.Upa.Types.Calendar.DAY_OF_WEEK; break; } case Net.Vpc.Upa.Expressions.DatePartType.DAYOFYEAR: { f = Net.Vpc.Upa.Types.Calendar.DAY_OF_YEAR; break; } case Net.Vpc.Upa.Expressions.DatePartType.HOUR: { f = Net.Vpc.Upa.Types.Calendar.HOUR; break; } case Net.Vpc.Upa.Expressions.DatePartType.MILLISECOND: { f = Net.Vpc.Upa.Types.Calendar.MILLISECOND; break; } case Net.Vpc.Upa.Expressions.DatePartType.MINUTE: { f = Net.Vpc.Upa.Types.Calendar.MINUTE; break; } case Net.Vpc.Upa.Expressions.DatePartType.SECOND: { f = Net.Vpc.Upa.Types.Calendar.SECOND; break; } case Net.Vpc.Upa.Expressions.DatePartType.MONTH: { f = Net.Vpc.Upa.Types.Calendar.MONTH; break; } case Net.Vpc.Upa.Expressions.DatePartType.WEEK: { f = Net.Vpc.Upa.Types.Calendar.WEEK_OF_MONTH; break; } case Net.Vpc.Upa.Expressions.DatePartType.YEAR: { f = Net.Vpc.Upa.Types.Calendar.YEAR; break; } case Net.Vpc.Upa.Expressions.DatePartType.DAYOFWEEKNAME: { switch (instance.Get(Net.Vpc.Upa.Types.Calendar.DAY_OF_WEEK)) { case 1: { return("Sunday"); } case 2: { return("Monday"); } case 3: { return("Tuesday"); } case 4: { return("Wednesday"); } case 5: { return("Thursday"); } case 6: { return("Friday"); } case 7: { return("Saturday"); } default: { return(""); } } } break; case Net.Vpc.Upa.Expressions.DatePartType.MONTHNAME: { switch (instance.Get(Net.Vpc.Upa.Types.Calendar.MONTH)) { case 1: { return("January"); } case 2: { return("February"); } case 3: { return("March"); } case 4: { return("April"); } case 5: { return("May"); } case 6: { return("June"); } case 7: { return("July"); } case 8: { return("August"); } case 9: { return("September"); } case 10: { return("October"); } case 11: { return("November"); } case 12: { return("December"); } default: { return(""); } } } break; default: { throw new System.Exception("Unsupported"); } } return(instance.Get(f)); }
public virtual void SetMax(Net.Vpc.Upa.Types.Date newMax) { max = newMax; }
public virtual void SetMin(Net.Vpc.Upa.Types.Date newMin) { min = newMin; }