Skip to content

Instantly share code, notes, and snippets.

@nikz
Created October 25, 2010 03:50
Show Gist options
  • Select an option

  • Save nikz/644352 to your computer and use it in GitHub Desktop.

Select an option

Save nikz/644352 to your computer and use it in GitHub Desktop.
def temporal_greeting(user, time_zone = ActiveSupport::TimeZone["Wellington"])
hour = Time.now.in_time_zone(time_zone).hour
case hour
when 6..12
"Good morning #{user.first_name}!"
when 12..17
"Afternoon, #{user.first_name}."
when 17..12
"Evening #{user.first_name}."
when 0..6
"Gosh #{user.first_name}, you're up late!"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment