lib/merch_calendar/util.rb in merch_calendar-0.1.0.rc1 vs lib/merch_calendar/util.rb in merch_calendar-0.1.0.rc2
- old
+ new
@@ -1,5 +1,8 @@
+require "merch_calendar/retail_calendar"
+require "merch_calendar/fiscal_year_calendar"
+
module MerchCalendar
# Utility methods for the merch calendar
module Util
@@ -83,21 +86,21 @@
# @param year [Fixnum] the merch year
# @param quarter [Fixnum] the quarter
#
# @return [Date] the starting date of the specified quarter
def start_of_quarter(year, quarter)
- retail_calendar.start_of_quarter(year, quarter)
+ fiscal_year_calendar.start_of_quarter(year + 1, quarter)
end
# The end date of the quarter
#
# @param year [Fixnum] the merch year
# @param quarter [Fixnum] the quarter
#
# @return [Date] the ending date of the specified quarter
def end_of_quarter(year, quarter)
- retail_calendar.end_of_quarter(year, quarter)
+ fiscal_year_calendar.end_of_quarter(year + 1, quarter)
end
# Returns the number of weeks in a given merch year
#
@@ -173,10 +176,14 @@
def retail_calendar
@retail_calendar ||= RetailCalendar.new
end
+ def fiscal_year_calendar
+ @fiscal_year_calendar ||= FiscalYearCalendar.new
+ end
+
# Reads the provided parameter and converts the value
# to a MERCH MONTH
def get_merch_month_param(param)
if param.is_a? Fixnum
return julian_to_merch(param)
@@ -197,8 +204,30 @@
end
# Load the utils into the MerchCalendar namespace
class << self
include Util
+ extend Gem::Deprecate
+
+ [
+ :start_of_week,
+ :end_of_week,
+ :start_of_month,
+ :end_of_month,
+ :start_of_year,
+ :end_of_year,
+ :weeks_in_year,
+ :merch_months_in,
+ ].each do |method|
+ deprecate method, "#{MerchCalendar::RetailCalendar}##{method}", DEPRECATION_DATE.year, DEPRECATION_DATE.month
+ end
+
+ [
+ :start_of_quarter,
+ :end_of_quarter
+ ].each do |method|
+ deprecate method, "#{MerchCalendar::FiscalYearCalendar}##{method}", DEPRECATION_DATE.year, DEPRECATION_DATE.month
+ end
+
end
end