
I was wondering why have restrictions on the datetime.time constructor arguments? For example, why can't you enter 1.5 minutes or 90 seconds to create a datetime object with 1 minute and 30 seconds?
I'd like to use datetime.time for time conversions like this. It seems silly to have to do all the math and sanitize the inputs manually. If I have to do all that work myself, then why use this module at all? Is there another module or function that I am missing? Thanks, Ben

On Sat, May 30, 2020 at 12:57 AM Ben Axelrod <ben@benaxelrod.com> wrote:
I think you're possibly misunderstanding the meaning of the time class. It's meant to represent a point during the day. If you want to represent the concept "one and a half minutes", what you want is the timedelta class instead, which *does* accept both floats and values beyond sixty:
datetime.timedelta(minutes=1.5) datetime.timedelta(seconds=90)
ChrisA

On Sat, May 30, 2020 at 12:57 AM Ben Axelrod <ben@benaxelrod.com> wrote:
I think you're possibly misunderstanding the meaning of the time class. It's meant to represent a point during the day. If you want to represent the concept "one and a half minutes", what you want is the timedelta class instead, which *does* accept both floats and values beyond sixty:
datetime.timedelta(minutes=1.5) datetime.timedelta(seconds=90)
ChrisA
participants (2)
-
Ben Axelrod
-
Chris Angelico