lib/tabs/resolutions/hour.rb in tabs-0.9.1 vs lib/tabs/resolutions/hour.rb in tabs-1.0.0
- old
+ new
@@ -1,13 +1,17 @@
module Tabs
module Resolutions
module Hour
- extend Tabs::Resolutionable
+ include Tabs::Resolutionable
extend self
PATTERN = "%Y-%m-%d-%H"
+ def name
+ :hour
+ end
+
def serialize(timestamp)
timestamp.strftime(PATTERN)
end
def deserialize(str)
@@ -15,9 +19,13 @@
self.normalize(dt)
end
def from_seconds(s)
s / 1.hour
+ end
+
+ def to_seconds
+ 1.hour
end
def add(ts, num)
ts + num.hours
end