added beginning of date math, moved script to separate file