class Playbook::PbDate::Date
def convert_to_timestamp(ts)
def convert_to_timestamp(ts) ts.is_a?(String) ? DateTime.parse(ts) : ts ts.in_time_zone(timezone_value) end
def day
def day timestamp.strftime("%e") end
def day_of_week
def day_of_week timestamp.strftime("%a").upcase end
def default_configuration
def default_configuration DEFAULT end
def display_value
def display_value size == "lg" ? display_value_lg : display_value_sm end
def display_value_lg
def display_value_lg if is_set? configured_timestamp pb_value_lg = Playbook::PbTitle::Title.new(size: 3, text: "#{month} #{day}") ApplicationController.renderer.render(partial: pb_value_lg, as: :object) end end
def display_value_sm
def display_value_sm if is_set? configured_timestamp pb_value = Playbook::PbBody::Body.new(color: "default") do icon + text end ApplicationController.renderer.render(partial: pb_value, as: :object) end end
def icon
def icon pb_icon = Playbook::PbIcon::Icon.new(icon: "calendar", fixed_width: true) ApplicationController.renderer.render(partial: pb_icon, as: :object) end
def initialize(classname: default_configuration,
def initialize(classname: default_configuration, data: default_configuration, id: default_configuration, size: default_configuration, timestamp: default_configuration, timezone: default_configuration) self.configured_classname = classname self.configured_data = data self.configured_id = id self.configured_size = size self.configured_timestamp = timestamp self.configured_timezone = timezone end
def kit_class
def kit_class "pb_date_kit" end
def month
def month timestamp.strftime("%^b").upcase end
def size
def size size_options = %w[lg sm] one_of_value(configured_size, size_options, "sm") end
def text
def text "<span>#{day_of_week} · #{month} #{day}</span>".html_safe end
def timestamp
def timestamp timestamp = convert_to_timestamp(configured_timestamp) end
def timezone_value
def timezone_value default_value(configured_timezone, "America/New_York") end
def to_partial_path
def to_partial_path "pb_date/date" end