Fix various date range related bugs
Merge pull request #3599 from dimagi/mapdates

Fix various date range related bugs