Seol mar théacs é seo: A Theory of Ultimately Periodic Languages and Automata With an Application to Time Granularity