Class: Towsta::Kinds::DatetimeKind

Inherits:
MainKind
  • Object
show all
Defined in:
lib/towsta/kinds/datetime.rb

Instance Attribute Summary

Attributes inherited from MainKind

#content

Instance Method Summary collapse

Methods inherited from MainKind

#compare, #compare_parameterized, #get, #initialize, #kind

Constructor Details

This class inherits a constructor from Towsta::Kinds::MainKind

Instance Method Details

#exportObject



15
16
17
18
# File 'lib/towsta/kinds/datetime.rb', line 15

def export
  return @content.strftime('%m/%d/%Y %H:%M') if @content.class == Time
  @content.to_s
end

#set(content) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/towsta/kinds/datetime.rb', line 6

def set content
  return @content = content if content.class == Time
  begin
    @content = DateTime.strptime(content, '%m/%d/%Y %H:%M').to_time
  rescue
    @content = nil
  end
end