[WIP] Fix duplicate date functions. Implements #10220

Do not merge. Pending feedback on solution.

@MorrisJobke