lib/google_otg.rb in google_otg-1.0.10 vs lib/google_otg.rb in google_otg-1.0.11

- old
+ new

@@ -203,13 +203,14 @@ raise ArgumentError, "Invalid object type. All objects must respond to 'count' and 'created_at'" end } tz = args.has_key?(:time_zone) ? args[:time_zone] : ActiveSupport::TimeZone['UTC'] - Time.zone = tz label = args.has_key?(:label) ? args[:label] : "Value" - time_fn = args.has_key?(:time_fn) ? args[:time_fn] : lambda {|h| h.created_at } + time_fn = args.has_key?(:time_fn) ? args[:time_fn] : lambda {|h| + return tz.local(h.created_at.year, h.created_at.month, h.created_at.day, h.created_at.hour, h.created_at.min, h.created_at.sec) # create zoned time + } range = args.has_key?(:range) ? args[:range] : DEFAULT_RANGE x_label_format = args.has_key?(:x_label_format) ? args[:x_label_format] : "%A %I:%M%p" max_y = 0 hits_dict = {} @@ -220,13 +221,13 @@ total = 0 points = [] point_dates = [] - now_days = Time.now # use this get the right year, month and day - now_minutes = Time.at((Time.now.to_i/(60*range))*(60*range)).gmtime - now_floored = Time.local(now_days.year, now_days.month, now_days.day, + now_days = tz.now # use this get the right year, month and day + now_minutes = tz.at((now_days.to_i/(60*range))*(60*range)).gmtime + now_floored = tz.local(now_days.year, now_days.month, now_days.day, now_minutes.hour, now_minutes.min, now_minutes.sec) current = hits.length > 0 ? time_fn.call(hits[0]) : now_floored while (current < now_floored + range.minutes && range > 0) do @@ -265,10 +266,10 @@ ## Setup X axis labels x_labels = [] max_x_label_count = args.has_key?(:max_x_label_count) ? args[:max_x_label_count] : points.length if points.length > 0 - step = points.length / max_x_label_count + step = [points.length / max_x_label_count, 1].max idx = 0 while idx < points.length point = points[idx] date = point_dates[idx] \ No newline at end of file