optimize date calculations