I would make a custom type (like a struct or class) an inside there create a function that does the conversion for you.
To actually go about doing it, it’ll depend on the format of the input is. Is it a Date
or a string that needs to be converted to a date? Etc
I’d suggest turning the input into minutes or hours and from there doing the conversion to metric