Sha256: e4b87b67db8af04f842330595a7551d69aef8ae69e2cc2d8a75dad4b23e65853

Contents?: true

Size: 691 Bytes

Versions: 5

Compression:

Stored size: 691 Bytes

Contents

require "time"

module Insulin
# Author::  Sam (mailto:sam@cruft.co)
# License:: MIT

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

    # Parse the strind 'd', looking for datetime information
    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']}" 
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
insulin-0.0.13 lib/insulin/on_track_date.rb
insulin-0.0.12 lib/insulin/on_track_date.rb
insulin-0.0.11 lib/insulin/on_track_date.rb
insulin-0.0.10 lib/insulin/on_track_date.rb
insulin-0.0.9 lib/insulin/on_track_date.rb