You can’t put time dependent things inside functions, as you’ve discovered
But you can parameterize custom events. And then really, what is the different between that and a function?