js logic for date comparisons