Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # File lib/active_warehouse/builder/date_dimension_builder.rb, line 31
- 31: def build(options={})
- 32: records = []
- 33: date = start_date.to_time
- 34: while date <= end_date.to_time
- 35: record = {}
- 36: record[:date] = date.strftime("%m/%d/%Y")
- 37: record[:full_date_description] = date.strftime("%B %d,%Y")
- 38: record[:day_of_week] = date.strftime("%A")
- 39: #record[:day_number_in_epoch] = date.to_i / 24
- 40: #record[:week_number_in_epoch] = date.to_i / (24 * 7)
- 41: #record[:month_number_in_epoch] = date.to_i / (24 * 7 * 30)
- 42: record[:day_number_in_calendar_month] = date.day
- 43: record[:day_number_in_calendar_year] = date.yday
- 44: record[:day_number_in_fiscal_month] = date.day # should this be different from CY?
- 45: record[:day_number_in_fiscal_year] = date.fiscal_year_yday
- 46: #record[:last_day_in_week_indicator] =
- 47: #record[:last_day_in_month_indicator] =
- 48: #record[:calendar_week_ending_date] =
- 49: record[:calendar_week] = "Week #{date.week}"
- 50: record[:calendar_week_number_in_year] = date.week
- 51: record[:calendar_month_name] = date.strftime("%B")
- 52: record[:calendar_month_number_in_year] = date.month
- 53: record[:calendar_year_month] = date.strftime("%Y-%m")
- 54: record[:calendar_quarter] = "Q#{date.quarter}"
- 55: record[:calendar_quarter_number_in_year] = date.quarter
- 56: record[:calendar_year_quarter] = "#{date.strftime('%Y')}-#{record[:calendar_quarter]}"
- 57: #record[:calendar_half_year] =
- 58: record[:calendar_year] = "#{date.year}"
- 59: record[:fiscal_week] = "FY Week #{date.fiscal_year_week}"
- 60: record[:fiscal_week_number_in_year] = date.fiscal_year_week
- 61: record[:fiscal_month] = date.fiscal_year_month
- 62: record[:fiscal_month_number_in_year] = date.fiscal_year_month
- 63: record[:fiscal_year_month] = "FY#{date.fiscal_year}-" + date.fiscal_year_month.to_s.rjust(2, '0')
- 64: record[:fiscal_quarter] = "FY Q#{date.fiscal_year_quarter}"
- 65: record[:fiscal_year_quarter] = "FY#{date.fiscal_year}-Q#{date.fiscal_year_quarter}"
- 66: record[:fiscal_year_quarter_number] = date.fiscal_year_quarter
- 67: #record[:fiscal_half_year] =
- 68: record[:fiscal_year] = "FY#{date.fiscal_year}"
- 69: record[:fiscal_year_number] = date.fiscal_year
- 70: record[:holiday_indicator] = holiday_indicators.include?(date) ? 'Holiday' : 'Nonholiday'
- 71: record[:weekday_indicator] = weekday_indicators[date.wday]
- 72: record[:selling_season] = 'None'
- 73: record[:major_event] = 'None'
- 74: record[:sql_date_stamp] = date
- 75:
- 76: records << record
- 77: date = date.tomorrow
- 78: end
- 79: records
- 80: end
Add Comment
Please, Sign In to add comment