-
Notifications
You must be signed in to change notification settings - Fork 0
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
base: master
Are you sure you want to change the base?
Conversation
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] |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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(',', '') } |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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', |
There was a problem hiding this comment.
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
@@ -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] |
There was a problem hiding this comment.
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!
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