Skip to content

Instantly share code, notes, and snippets.

@davidcelis
Created March 11, 2014 18:18

Revisions

  1. David Celis created this gist Mar 11, 2014.
    20 changes: 20 additions & 0 deletions business_hours_feature.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    require 'active_support/core_ext/time'

    class BusinessHoursFeature
    # This feature is only available between the hours of 10am and 4pm
    def enabled?
    Time.use_zone('Pacific Time (US & Canada)') do
    now = Time.zone.now
    am, pm = Time.zone.parse('10:00'), Time.zone.parse('16:00')
    weekday = !(now.saturday? || now.sunday?)

    now.between?(am, pm) && weekday
    end
    end
    end

    module Features
    class NewRelicSingleSignOn < BusinessHoursFeature; end
    end

    Features::NewRelicSingleSignOn.new.enabled?