Sneaky Abstractions

Subscribe to my Feed, follow me on , recommend me on Working With Rails or see my code on GitHub

Ready to take my clothes off

Posted on April 04, 2008 09:55 Tagged with naked day, css, web standards.

April 9 is CSS Naked Day. Here’s a simple Rails helper that determines if Time.now is naked day:

def naked_day?(day=9, month=4)
  start = Time.utc(Time.now.year, month, day) - 12.hours
  stop = Time.utc(Time.now.year, month, day) + 36.hours
  now = Time.now.utc

  now > start && now < stop
end

(Naked day lasts for 48 hours, 24 + 1 hour for each timezone)

Put it in application_helper.rb, and you can use it in your layout like this:

<head>
  <% unless naked_day? -%>
    <%= stylesheet_link_tag 'application' %>
  <% end -%>
</head>

Love everybody and everything, all the time.