Class: Readiness::Dates
- Inherits:
-
Object
- Object
- Readiness::Dates
- Defined in:
- lib/support_readiness/dates.rb
Overview
Defines the class Dates within the module Readiness.
Class Method Summary collapse
-
.current_quarter ⇒ String
Return the current GitLab quarter as of the current date in format “FY##Q#”.
-
.determine_quarter(date) ⇒ String
Returns the GitLab quarter in format “FY##Q#” from a give date.
-
.next_quarter(date = Time.now) ⇒ String
Return the next GitLab quarter in format “FY##Q#”.
-
.previous_quarter(date = Time.now) ⇒ String
Return the previous GitLab quarter in format “FY##Q#”.
Class Method Details
.current_quarter ⇒ String
Return the current GitLab quarter as of the current date in format “FY##Q#”
19 20 21 |
# File 'lib/support_readiness/dates.rb', line 19 def self.current_quarter determine_quarter(Time.now) end |
.determine_quarter(date) ⇒ String
Returns the GitLab quarter in format “FY##Q#” from a give date
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/support_readiness/dates.rb', line 72 def self.determine_quarter(date) date = Time.parse(date) unless [DateTime, Date, Time].include? date.class month = date.month year = date.year.digits(100).first case month when 1 "FY#{year}Q4" when 2..4 "FY#{year + 1}Q1" when 5..7 "FY#{year + 1}Q2" when 8..10 "FY#{year + 1}Q3" when 11..12 "FY#{year + 1}Q4" end end |
.next_quarter(date = Time.now) ⇒ String
Return the next GitLab quarter in format “FY##Q#”. Defaults to assuming you mean for the current date
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/support_readiness/dates.rb', line 32 def self.next_quarter(date = Time.now) current = determine_quarter(date) year = current.split('Q').first.split('FY').last.to_i quarter = current.split('Q').last.to_i if quarter == 4 "FY#{year + 1}Q1" else "FY#{year}Q#{quarter + 1}" end end |
.previous_quarter(date = Time.now) ⇒ String
Return the previous GitLab quarter in format “FY##Q#”. Defaults to assuming you mean for the current date
52 53 54 55 56 57 58 59 60 61 |
# File 'lib/support_readiness/dates.rb', line 52 def self.previous_quarter(date = Time.now) current = determine_quarter(date) year = current.split('Q').first.split('FY').last.to_i quarter = current.split('Q').last.to_i if quarter == 1 "FY#{year - 1}Q4" else "FY#{year}Q#{quarter - 1}" end end |