PR description:
This will be used primarily by the addr time refactor (core#24697) to make addr relay time type safe. However, it can also be used in other places, and can be reviewed independently.
This is a backport of core#25101
Depends on D14911