Sha256: 62def56c4c58efba3e853f50238643aae78828c806e5662c646841dbf861b955

Contents?: true

Size: 739 Bytes

Versions: 6

Compression:

Stored size: 739 Bytes

Contents

require "time"

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

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

      # Parse the string '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
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
insulin-0.1.0 lib/insulin/on_track/date.rb
insulin-0.0.18 lib/insulin/on_track/date.rb
insulin-0.0.17 lib/insulin/on_track/date.rb
insulin-0.0.16 lib/insulin/on_track/date.rb
insulin-0.0.15 lib/insulin/on_track/date.rb
insulin-0.0.14 lib/insulin/on_track/date.rb