Sha256: 3d416f7b9a4ae4a05b4ccd76e84d0c9f524544adddea6bb6139c15894c3be211
Contents?: true
Size: 1.22 KB
Versions: 1
Compression:
Stored size: 1.22 KB
Contents
module ETL #:nodoc: module CoreExtensions #:nodoc: module Time #:nodoc: # Enables the use of time calculations within Time itself module Calculations def week cyw = ((yday - 1) / 7) + 1 cyw = 52 if cyw == 53 cyw end def quarter ((month - 1) / 3) + 1 end def fiscal_year_week(offset_month=10) fyw = ((fiscal_year_yday(offset_month) - 1) / 7) + 1 fyw = 52 if fyw == 53 fyw end def fiscal_year_month(offset_month=10) shifted_month = month - (offset_month - 1) shifted_month += 12 if shifted_month < 0 shifted_month end def fiscal_year_quarter(offset_month=10) ((fiscal_year_month(offset_month) - 1) / 3) + 1 end def fiscal_year(offset_month=10) month >= offset_month ? year + 1 : year end def fiscal_year_yday(offset_month=10) offset_days = 0 1.upto(offset_month - 1) { |m| offset_days += ::Time.days_in_month(m, year) } shifted_year_day = yday - offset_days shifted_year_day += 365 if shifted_year_day <= 0 shifted_year_day end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
activewarehouse-etl-0.9.0 | lib/etl/core_ext/time/calculations.rb |