brick / date-time

Date and time library for PHP
MIT License
337 stars 30 forks source link

Why no float in Period ? #29

Closed sducamp closed 4 years ago

sducamp commented 4 years ago

Hi,

Just for my own knowledge, why don't you use float to represent the duration ? For exemple, if I have 5400 seconds, I expect that the toHours() method returns 1.5.

Thank you in advance for your reply.

BenMorel commented 4 years ago

Hi, this has been modeled after Java's Duration, which does the same:

https://docs.oracle.com/javase/8/docs/api/java/time/Duration.html

What's your use case?

sducamp commented 4 years ago

Hi, thank you for your response.

My use case is, at some point I get a Duration of 20736 seconds and I need to display this Duration to the final user in hours like 5,76 hours. I expect that the toHours() method gives me the solution but not. So I need to do manually toSeconds() / 3600.

BenMorel commented 4 years ago

So I need to do manually toSeconds() / 3600.

That seems reasonable to me!