Class: ZTimeLabelHour

Inherits:
ZTimeLabel show all
Defined in:
lib/z_time_label_hour.rb

Constant Summary

Constants inherited from ZTimeLabel

ZTimeLabel::TZ_INT_MAP

Instance Attribute Summary

Attributes inherited from ZTimeLabel

#css_classes, #endtime, #starttime, #title

Class Method Summary collapse

Methods inherited from ZTimeLabel

get_all_blocks, #initialize, offset_from_rid, time_blocks_starting_through, tz_from_rid

Constructor Details

This class inherits a constructor from ZTimeLabel

Class Method Details

.daylight_class(t) ⇒ Object



13
14
15
# File 'lib/z_time_label_hour.rb', line 13

def self.daylight_class(t)
  (6...18).include?(t.hour) ? 'dayTimeblock' : 'niteTimeblock'
end

.end_for_start(t) ⇒ Object



17
18
19
# File 'lib/z_time_label_hour.rb', line 17

def self.end_for_start( t )
  floor(t) + 15.minutes
end

.floor(t) ⇒ Object

t is a TimeWithZone or similar



22
23
24
# File 'lib/z_time_label_hour.rb', line 22

def self.floor(t)
  t.change(min: (t.min / 15) * 15)
end

.get_timeblocks(id, t1, t2, inc) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/z_time_label_hour.rb', line 5

def self.get_timeblocks(id, t1, t2, inc)
  (super).each do |b|
    t = b.starttime
    b.title = t.strftime('%I:%M').sub(/^0/, '')     # '%I'
    b.css_classes = "ZTimeHeaderHourRow #{daylight_class(t)} "
  end
end