Calendar manipulation optimizations suggested by deinspanjer