module ZTK::GoogleChart::Base::Dates

Constants

DATE_HELPERS

Public Instance Methods

date_format(*args) click to toggle source
# File lib/ztk/google_chart/base/dates.rb, line 61
def date_format(*args)
  %w( %Y %%d %-d %-H %-M %-S )[*args].join(',')
end
date_scale(scale, *args) click to toggle source
# File lib/ztk/google_chart/base/dates.rb, line 16
def date_scale(scale, *args)
  case scale
  when :year then
    send(:date_month, *args)
  when :month, :week then
    send(:date_day, *args)
  when :day then
    send(:date_hour, *args)
  when :hour then
    send(:date_minute, *args)
  when :minute then
    send(:date_second, *args)
  end
end
date_seed(start_time, end_time, unit, default) click to toggle source
# File lib/ztk/google_chart/base/dates.rb, line 31
def date_seed(start_time, end_time, unit, default)
  start_time = start_time.dup
  timeline = Hash.new

  scale = case unit
  when :year then
    :month
  when :month, :week then
    :day
  when :day then
    :hour
  when :hour then
    :minute
  when :minute then
    :second
  end

  loop do
    timeline.merge!(date_scale(unit, start_time) => default.dup)
    start_time += 1.send(scale)
    break if (start_time > end_time)
  end

  timeline
end
date_wrapper(value) click to toggle source
# File lib/ztk/google_chart/base/dates.rb, line 57
def date_wrapper(value)
  "new Date(#{value})"
end