lib/tabs/helpers.rb in tabs-0.7.1 vs lib/tabs/helpers.rb in tabs-0.8.0
- old
+ new
@@ -12,24 +12,12 @@
end
end
end
def normalize_period(period, resolution)
- period_start = Tabs::Resolution.normalize(resolution, period.first)
- period_end = Tabs::Resolution.normalize(resolution, period.last)
+ period_start = Tabs::Resolution.normalize(resolution, period.first.utc)
+ period_end = Tabs::Resolution.normalize(resolution, period.last.utc)
(period_start..period_end)
- end
-
- def extract_date_from_key(stat_key, resolution)
- date_str = stat_key.split(":").last
- Tabs::Resolution.deserialize(resolution, date_str)
- end
-
- def fill_missing_dates(period, date_value_pairs, resolution, default_value=0)
- all_timestamps = timestamp_range(period, resolution)
- default_value_timestamps = Hash[all_timestamps.map { |t| [t, default_value] }]
- merged = default_value_timestamps.merge(Hash[date_value_pairs])
- merged.to_a
end
def round_float(f)
(f*100).round / 100.0
end