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

A 11393 fix specs and ignore commas #3

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

bpaul
Copy link

@bpaul bpaul commented Mar 23, 2021

I updated the gem to ignore the thousands delimiters in input strings.

As part of this I fixed the specs which hadn't been updated since we moved to work-days. While fixing the specs I found a bug in our handling of longer timeframes (ie year plus) and fixed that too

Change examples to use work days
Remove weeks from examples as we don't support them anymore
Remove empty context
Move short minute from m to min
@@ -47,7 +47,7 @@ def output(seconds, opts = {})
month = 22 * day
year = 260 * day

if seconds >= 31557600 && seconds%year < seconds%month
if seconds >= year && !opts[:limit_to_hours]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how this ever worked before.

  • The 31557600 refers to a full year not a working year.
  • seconds%year < seconds%month just doesn't make sense to me

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no idea what seconds%year < seconds%month means!

@@ -151,6 +151,7 @@ def calculate_from_words(string, opts)

def cleanup(string)
res = string.downcase
res = res.gsub(/[0-9]*\,?[0-9]+/) { |m| m.gsub(',', '') }
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is my fix for the thousands delimiter ie 1,000 seconds. See test below

work_day = 8 * hour
work_month = 22 * work_day
work_year = 260 * work_day
work_week = 5 * work_day
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update specs to use work days, weeks, months and years

@@ -82,84 +87,68 @@
@exemplars = {
(60 + 20) =>
{
:micro => '1m20s',
:short => '1m 20s',
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use min not m as our short minute delimiter

@bpaul bpaul requested review from jjbohn, a team and philwilt and removed request for a team March 23, 2021 16:41
@@ -47,7 +47,7 @@ def output(seconds, opts = {})
month = 22 * day
year = 260 * day

if seconds >= 31557600 && seconds%year < seconds%month
if seconds >= year && !opts[:limit_to_hours]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no idea what seconds%year < seconds%month means!

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.

3 participants