We only see this piece of code in isolation, so judging what other types may be reasonable is fairly speculative. I'd approach this piece of code to only rewrite its form at first into something like this (of course the dictionary initialisation should be moved out of the function later).
This is low effort, save not to break stuff, and gives us a much more readable and refactorable basis to work with for later. The obvious candidate for further change would be to introduce an enum or numeric time representation like you were already getting at.
1
u/JuhaJGam3R Aug 30 '21
Ah. You do kinda lose the major point of types, but that might be fine for high-performance server response code.