Class: Tomlrb::LocalDateTime

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/llm/shell/internal/tomlrb/lib/tomlrb/local_date_time.rb

Instance Method Summary collapse

Constructor Details

#initialize(year, month, day, hour, min, sec) ⇒ LocalDateTime

rubocop:disable Metrics/ParameterLists



11
12
13
14
# File 'lib/llm/shell/internal/tomlrb/lib/tomlrb/local_date_time.rb', line 11

def initialize(year, month, day, hour, min, sec) # rubocop:disable Metrics/ParameterLists
  @time = Time.new(year, month, day, hour, min, sec, '-00:00')
  @sec = sec
end

Instance Method Details

#==(other) ⇒ Object



33
34
35
36
# File 'lib/llm/shell/internal/tomlrb/lib/tomlrb/local_date_time.rb', line 33

def ==(other)
  other.is_a?(self.class) &&
    to_time == other.to_time
end

#inspectObject



38
39
40
# File 'lib/llm/shell/internal/tomlrb/lib/tomlrb/local_date_time.rb', line 38

def inspect
  "#<#{self.class}: #{self}>"
end

#to_sObject



27
28
29
30
31
# File 'lib/llm/shell/internal/tomlrb/lib/tomlrb/local_date_time.rb', line 27

def to_s
  frac = (@sec - sec)
  frac_str = frac.zero? ? '' : frac.to_s[1..-1]
  @time.strftime('%FT%T') << frac_str
end

#to_time(offset = '-00:00') ⇒ Time



22
23
24
25
# File 'lib/llm/shell/internal/tomlrb/lib/tomlrb/local_date_time.rb', line 22

def to_time(offset = '-00:00')
  return @time if offset == '-00:00'
  Time.new(year, month, day, hour, min, @sec, offset)
end