Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Dates and Times in Python (2014) Where on Earth do Timezones Make Sense? Introduction to Timezones

spencer tintorri
spencer tintorri
6,184 Points

For mumbai, is there an advantage to using hours=5, minutes=30 instead of just using hours=5.5 ?

See above. Thank you.

1 Answer

Jeff Muday
MOD
Jeff Muday
Treehouse Moderator 28,720 Points

That is an excellent question-- you are really paying close attention to Kenneth's teaching!

Even though Datetime objects in representation __repr__ are made up of integers rounded to the nearest microsecond (e.g. 10^-9). According to the official documentation, it should not be a problem to use a float for hours.

quote:

All arguments are optional and default to 0. Arguments may be integers or floats, and may be positive or negative.

https://docs.python.org/3/library/datetime.html#:~:text=A%20timedelta%20object%20represents%20a,may%20be%20positive%20or%20negative.

If you are a Python geek like me, you may want to look over the code. There are a number of // (floor division) operators involved in conversions. This means there are quite a bit of floating point operations taking place internally that require conversion back to integers.

https://github.com/python/cpython/blob/3.8/Lib/datetime.py

Good luck with your Python journey!