Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change Time class to extract additional constants for numbers which are used in multiple calculations #5242

Closed
wants to merge 1 commit into from

Conversation

lachlan
Copy link
Contributor

@lachlan lachlan commented Nov 4, 2017

A small change to extract some more constants for numbers used in multiple calculations.

@RX14
Copy link
Contributor

RX14 commented Nov 4, 2017

I tend to think that extracting constants for the sake of extracting constants is pointless and unneccesary. Everyone knows there are 24 hours in a day and 7 days in a week. There's little benefit in this change and its much more verbose.

@lachlan
Copy link
Contributor Author

lachlan commented Nov 4, 2017

This change came about because I noticed the SECONDS_PER_* and NANOSECONDS_PER_* calculations specify their operands inconsistently:

SECONDS_PER_HOUR = 60 * SECONDS_PER_MINUTE
NANOSECONDS_PER_MINUTE = NANOSECONDS_PER_SECOND * 60

So I wanted to fix that, and since I was changing the calculation anyway I thought why not make the calculation more understandable, since 60 can be seconds per minute or minutes per hour. It's a small ambiguity, but an ambiguity none the less.

We can make the constants private, if we don't want them in the API. Or I can remove the new constants and just fix the ordering of the operands to be consistent across the existing constants? Or we can abandon this change altogether if there's no interest?

@asterite
Copy link
Member

The introduced constants are well known. Everyone knows how many hours are per day, or how many days are in a week. It's a bit more tricky to quickly remember the number of seconds in an hour, plus seeing 3600 is not immediately obvious that that's the meaning. Thank you, in any case!

@asterite asterite closed this Apr 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants