[WIP] Fix duplicate date functions. Implements #10220

Do not merge. Pending feedback on solution.

@MorrisJobke 
Rebase and use Travis ;) (PR was merged this morning)