Fix iterating over DateTime by doing strict checking for Time objects

- Fixes #13667
Merge pull request #13668 from prathamesh-sonpatki/issue-13667

Fix iterating over DateTime by doing strict checking for Time objects