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

Format: fix to use right alignment only if all whens are number literal #6392

Conversation

makenowjust
Copy link
Contributor

Fix #6366

#6366 example is now formatted to:

def to_pretty(t)
  a = (Time.now - t).to_i

  case a
  when 0               then "just now"
  when 1               then "a second ago"
  when 2..59           then a.to_s + " seconds ago"
  when 60..119         then "a minute ago" # 120 = 2 minutes
  when 120..3540       then (a/60).to_i.to_s + " minutes ago"
  when 3541..7100      then "an hour ago" # 3600 = 1 hour
  when 7101..82800     then ((a + 99)/3600).to_i.to_s + " hours ago"
  when 82801..172000   then "a day ago" # 86400 = 1 day
  when 172001..518400  then ((a + 800)/(60*60*24)).to_i.to_s + " days ago"
  when 518400..1036800 then "a week ago"
  else                      ((a + 180000)/(60*60*24*7)).to_i.to_s + " weeks ago"
  end
end

@RX14 RX14 added this to the Next milestone Jul 16, 2018
@RX14 RX14 merged commit 210d8ef into crystal-lang:master Jul 16, 2018
@RX14 RX14 modified the milestones: Next, 0.26.0 Jul 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants