 
       return clamp(interval, @min_interval, @max_interval)
 
-  copy_date = (date) ->
-    return new Date(date.getTime())
-
-  last_month_no_later_than = (date) ->
-    date = copy_date(date)
-    date.setUTCDate(1)
-    date.setUTCHours(0)
-    date.setUTCMinutes(0)
-    date.setUTCSeconds(0)
-    date.setUTCMilliseconds(0)
-    return date
-
-  last_year_no_later_than = (date) ->
-    date = last_month_no_later_than(date)
-    date.setUTCMonth(0)
-    return date
-
-  date_range_by_year = (start_time, end_time) ->
-    start_date = last_year_no_later_than(new Date(start_time))
-
-    end_date = last_year_no_later_than(new Date(end_time))
-    end_date.setUTCFullYear(end_date.getUTCFullYear() + 1)
-
-    dates = []
-    date = start_date
-    while true
-      dates.push(copy_date(date))
-
-      date.setUTCFullYear(date.getUTCFullYear() + 1)
-      if date > end_date
-        break
-
-    return dates
-
-  date_range_by_month = (start_time, end_time) ->
-    start_date = last_month_no_later_than(new Date(start_time))
-
-    end_date = last_month_no_later_than(new Date(end_time))
-    # XXX This is not a reliable technique in general, but it should be
-    # safe when the day of the month is 1.  (The problem case is this:
-    # Mar 31 -> Apr 31, which becomes May 1.)
-    prev_end_date = copy_date(end_date)
-    end_date.setUTCMonth(end_date.getUTCMonth() + 1)
-
-    dates = []
-    date = start_date
-    while true
-      dates.push(copy_date(date))
-
-      date.setUTCMonth(date.getUTCMonth() + 1)
-      if date > end_date
-        break
-
-    return dates
-
+  # A MonthsScale produces ticks from a fixed subset of months of the year.
+  # E.g., MonthsScale([0, 3, 6, 9]) produces ticks of the 1st of January,
+  # April, July, and October of each year.
   class MonthsScale extends SingleIntervalScale
     constructor: (@months) ->
       @typical_interval = if @months.length > 1


      return ticks_in_range

  class DaysScale extends SingleIntervalScale
    constructor: (@days) ->
      @typical_interval = if @days.length > 1

  ONE_MONTH = 30 * ONE_DAY # An approximation, obviously.
  ONE_YEAR = 365 * ONE_DAY

  # This is a good default scale for generic numerical data.
  class BasicScale extends AdaptiveScale
    constructor: () ->
      super([1, 2, 5])

  # This is a decent scale for time data (in milliseconds).
  # It could certainly be improved:
  # FIXME There should probably be a special scale for years.
  # FIXME Some of the adaptive scales probably have too many mantissas, which
  # leads to too-frequent tick transitions.
  class DatetimeScale extends CompositeScale
    constructor: () ->
      super([
