params = new Type[] {};
functions.add(new LibraryFunction("today_to_holiday", DataTypes.STRING_TYPE,params));
params = new Type[] {};
functions.add(new LibraryFunction("tommorrow_to_holiday",DataTypes.STRING_TYPE,params));
params = new Type[] {};
functions.add(new LibraryFunction("predict_holiday",DataTypes.STRING_TYPE,params));
public static Value today_to_holiday(Interpreter interpreter)
{
return new Value(HolidayDatabase.getHoliday(false));
}
public static Value predict_holiday(Interpreter interpreter)
{
return new Value(HolidayDatabase.getHoliday(true));
}
public static Value tommorrow_to_holiday(Interpreter interpreter)
{
Date d=new Date();
Calendar cal = Calendar.getInstance();
cal.setTime(d);
cal.add(Calendar.DATE, 1);
return new Value(HolidayDatabase.getHoliday(cal.getTime(),false));
}
params = new Type[]{DataTypes.INT_TYPE};
functions.add(new LibraryFunction("future_to_holiday",DataTypes.STRING_TYPE,params));
public static Value future_to_holiday(Interpreter interpreter, Value days)
{
Date d=new Date();
Calendar cal=Calendar.getInstance();
cal.setTime(d);
cal.add(Calendar.DATE, (int)days.intValue());
return new Value(HolidayDatabase.getHoliday(cal.getTime(),false));
}
If something like tomorrow_to_holiday() was added, I think it would make more sense to allow an arbitrary offset as a parameter (with a different function name of course, though I'm not sure what a good name would be). I haven't looked at the code though.