squants icon indicating copy to clipboard operation
squants copied to clipboard

Add support for longer units of time

Open bbarker opened this issue 8 years ago • 6 comments
trafficstars

I'd be happy to tackle this but wanted to run it by others first. I'm primarily wanting: Weeks (28 days), Months (30 days), Years, GregorianYears.

Others that I may include while at it: Decade, Century, Millennium, and Fortnight (mostly for fun on this last one!).

Any comments/suggestions welcome.

bbarker avatar May 01 '17 13:05 bbarker

This got me wondering, months could be anywhere from 29-31 days, How'd you handle that Even years vary and not only by being leap years

cquiroz avatar May 01 '17 19:05 cquiroz

That's why I mentioned Year vs GregorianYear (the first is 365 days, the second is a bit off and would be defined down to the second to account for the average length of a year). Month is standardized at 30 days, I believe - if folks or looking for lengths of days for particular months, they would probably want to use a calendar library.

bbarker avatar May 01 '17 19:05 bbarker

Do you have a use case for this, or is this just a general request for enhancement? Trying how to understand where to define a boundary between squants' time units and a calendar library.

derekmorr avatar May 01 '17 20:05 derekmorr

I do have an application that makes heavy use of Months, and somewhat frequent use of Weeks and Years.

On Mon, May 1, 2017 at 4:15 PM, Derek Morr [email protected] wrote:

Do you have a use case for this, or is this just a general request for enhancement? Trying how to understand where to define a boundary between squants' time units and a calendar library.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/typelevel/squants/issues/228#issuecomment-298420739, or mute the thread https://github.com/notifications/unsubscribe-auth/AA37jnhS39F95ifRn4y3iYcEUvC91Q2dks5r1j1YgaJpZM4NNDx9 .

-- Brandon Barker [email protected]

bbarker avatar May 01 '17 20:05 bbarker

Adding a note to consider other time-derived quantities (e.g., MassFlow), so that one could do .toPoundsPerDay instead of toPoundsPerHour*24.

bbarker avatar Jun 23 '17 14:06 bbarker

Months, years and longer units of time are not regular and require a calendar to do those operations correctly. I think a week should be the longest unit of time as its the longs one that is regular.

hunterpayne avatar Feb 28 '19 06:02 hunterpayne