properly calculate date distance
cleanup unused functions