Skip to content

Add short format option#2

Open
Madh93 wants to merge 1 commit intodpzaba:masterfrom
Madh93:short-format-option
Open

Add short format option#2
Madh93 wants to merge 1 commit intodpzaba:masterfrom
Madh93:short-format-option

Conversation

@Madh93
Copy link
Copy Markdown

@Madh93 Madh93 commented Apr 23, 2018

Add a short format option.

10.seconds_in_words(short_format: true)
# => 10 s
(1.day + 1.hour + 1.minute + 40).seconds_in_words(short_format: true)
# => 1 d 1 h 1 m 40 s

@dpzaba
Copy link
Copy Markdown
Owner

dpzaba commented Aug 1, 2018

Hi @Madh93 I did not realize of this PR I did not get any notification, sorry for the delay. Give me some time to think about it, thanks.


if rest.nonzero? && !(unit_time == :seconds && opts[:skip_seconds])
word = I18n.t(unit_time.to_s, count: rest, scope: locale_prefix)
word = (opts[:short_format] ? word[0] : word)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

what do you think about instead of do word[0], to have a short_format in our locales somehow? No idea if word[0] works for all locales

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

It's a good idea.

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.

2 participants