Class: TimePresenter

Inherits:
Object
  • Object
show all
Defined in:
lib/glimmer-dsl-web/samples/hello/hello_input_date_time.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTimePresenter

Returns a new instance of TimePresenter.



27
28
29
# File 'lib/glimmer-dsl-web/samples/hello/hello_input_date_time.rb', line 27

def initialize
  @date_time = Time.now
end

Instance Attribute Details

#date_timeObject

Returns the value of attribute date_time.



25
26
27
# File 'lib/glimmer-dsl-web/samples/hello/hello_input_date_time.rb', line 25

def date_time
  @date_time
end

#month_stringObject

Returns the value of attribute month_string.



25
26
27
# File 'lib/glimmer-dsl-web/samples/hello/hello_input_date_time.rb', line 25

def month_string
  @month_string
end

#week_stringObject

Returns the value of attribute week_string.



25
26
27
# File 'lib/glimmer-dsl-web/samples/hello/hello_input_date_time.rb', line 25

def week_string
  @week_string
end

Instance Method Details

#date_time_stringObject



49
50
51
# File 'lib/glimmer-dsl-web/samples/hello/hello_input_date_time.rb', line 49

def date_time_string
  @date_time&.strftime('%Y-%m-%dT%H:%M')
end

#date_time_string=(value) ⇒ Object



53
54
55
56
57
58
59
60
# File 'lib/glimmer-dsl-web/samples/hello/hello_input_date_time.rb', line 53

def date_time_string=(value)
  if value.match(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}$/)
    date_time_parts = value.split('T')
    date_parts = date_time_parts.first.split('-')
    time_parts = date_time_parts.last.split(':')
    self.date_time = Time.new(*date_parts, *time_parts)
  end
end