Skip to content

Instantly share code, notes, and snippets.

@TravelingTechGuy
Created August 27, 2011 22:51
Show Gist options
  • Save TravelingTechGuy/1175969 to your computer and use it in GitHub Desktop.
Save TravelingTechGuy/1175969 to your computer and use it in GitHub Desktop.
Create a fuzzy, verbal clock
#!/usr/bin/env ruby
hour, minute = Time.now.strftime('%I').to_i, Time.now.min
ones = %w{ nil one two three four five six seven eight nine }
teens = %w{ ten eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen }
tens = %w{ nil nil twenty thirty forty fifty }
minute_str = case minute
when 0 then 'o-clock'
when 1..9 then "o-#{ones[minute]}"
when 10..19 then teens[minute - 10]
else tens[minute.to_s[0,1].to_i] + (minute.to_s[1,1].to_i == 0 ? '' : "-#{ones[minute.to_s[1,1].to_i]}")
end
print "#{[ones,teens].flatten[hour]} #{minute_str}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment