class UKClockChange

Public Class Methods

back() click to toggle source
# File lib/ukclockchange.rb, line 28
def self.back()
  clockchange()
end
clockchange(s="last Sunday in October at 2am") click to toggle source
# File lib/ukclockchange.rb, line 36
def self.clockchange(s="last Sunday in October at 2am")

  t = ChronicCron.new(s).to_time
  seconds = (t - Time.now).to_i
  days = (t.to_date - Time.now.to_date).to_i

  {
    change: s =~ /October/ ? :back : :forward,
    date: t.to_date,
    days_remaining: days, 
    countdown_duration: ChronicDuration.output(seconds, units: 2),
    formatted_date: t.to_date.humanize
  }
end
forward() click to toggle source
# File lib/ukclockchange.rb, line 32
def self.forward()
  clockchange("last Sunday in March at 1am")
end
next() click to toggle source
# File lib/ukclockchange.rb, line 24
def self.next()
  Time.now.dst? ? self.back : self.forward
end