Class: Insulin::OnTrack::Date

Inherits:
Hash
  • Object
show all
Defined in:
lib/insulin/on_track/date.rb

Overview

OnTrack uses really shitty date formats, including embedding a comma in the CSV export file. Christ on a crutch

Instance Method Summary collapse

Constructor Details

#initialize(d) ⇒ Date

Parse the string ā€˜dā€™, looking for datetime information



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/insulin/on_track/date.rb', line 13

def initialize d
  t = Time.parse d

  # We extract loads of stuff. Might be useful one day
  self["timestamp"] = t
  self["tzoffset"] = t.strftime "%z"
  self["timezone"] = t.zone
  self["unixtime"] = t.to_i
  self["day"] = t.strftime("%A").downcase
  self["date"] = t.strftime "%F"
  self["time"] = t.strftime "%T #{self['timezone']}" 
  self["short_time"] = t.strftime "%H:%M" 
end