moved time method logic from html