Returns a collection of months by associated quarter

@param integer $quarter
@throws \LogicException If invalid quarter supplied
@return array
190857
public static function getAllMonthsByQuarter($quarter)
    {
        switch ($quarter) {
            case 1:
                return self::getMonthsByQuarter(1);
            case 2:
                return array_merge(self::getMonthsByQuarter(1), self::getMonthsByQuarter(2));
            case 3:
                return array_merge(self::getMonthsByQuarter(1), self::getMonthsByQuarter(2), self::getMonthsByQuarter(3));
            case 4:
                return array_merge(self::getMonthsByQuarter(1), self::getMonthsByQuarter(2), self::getMonthsByQuarter(3), self::getMonthsByQuarter(4));
            default:
                throw new LogicException(sprintf('Invalid quarter supplied - %s', $quarter));
        }
    }
573466
public static function nextMonth($month, $year)
    {
        if ($year >= 1970) {
            if ($month >= 12) {
                $nextMonth = 1;
                $yearMonth = $year + 1;
            } else {
                $nextMonth = $month + 1;
                $yearMonth = $year;
            }
        }

        return array('month' => $nextMonth, 'year' => $yearMonth);
    }
283349
public function getRelativeMonthCount($end = null, $locale = null, $query = null, $cacheKey = null)
    {
        if (is_null($end))
        {
            $end = Carbon::today();
        }

        return $this->getCountInBetween($end->copy()->subMonth()->addDay()->startOfDay(), $end->endOfDay(), $locale, $query, $cacheKey);
    }
996242
function quarterFormat() {

  const format = function(d) {
    return formats.year.data(d) + "q" + formatQuarter(d);
  };

  format.parse = function(dateString) {
    const matchedDate = dateString.match(/^(\d{4})q(\d)$/);
    return matchedDate ? getDateFromQuarter(matchedDate[1], matchedDate[2]) : null;
  };

  const formatQuarter = function(d) {
    if (!(d instanceof Date)) d = new Date(+d);
    return ((d.getUTCMonth() / 3) | 0) + 1;
  };

  const getDateFromQuarter = function(p1, p2) {
    const quarter = parseInt(p2);
    const month = 3 * quarter - 2; // first month in quarter
    const year = p1;
    return formats.month.data.parse([year, (month < 9 ? "0" : "") + month].join("-"));
  };

  return format;
}
149282
def get_term_before(aterm):
    
    prev_year = aterm.year
    prev_quarter = QUARTER_SEQ[QUARTER_SEQ.index(aterm.quarter) - 1]

    if prev_quarter == "autumn":
        prev_year -= 1

    return get_term_by_year_and_quarter(prev_year, prev_quarter)
198776
private function axisMonths(): array
    {
        return [
            'JAN' => I18N::translateContext('NOMINATIVE', 'January'),
            'FEB' => I18N::translateContext('NOMINATIVE', 'February'),
            'MAR' => I18N::translateContext('NOMINATIVE', 'March'),
            'APR' => I18N::translateContext('NOMINATIVE', 'April'),
            'MAY' => I18N::translateContext('NOMINATIVE', 'May'),
            'JUN' => I18N::translateContext('NOMINATIVE', 'June'),
            'JUL' => I18N::translateContext('NOMINATIVE', 'July'),
            'AUG' => I18N::translateContext('NOMINATIVE', 'August'),
            'SEP' => I18N::translateContext('NOMINATIVE', 'September'),
            'OCT' => I18N::translateContext('NOMINATIVE', 'October'),
            'NOV' => I18N::translateContext('NOMINATIVE', 'November'),
            'DEC' => I18N::translateContext('NOMINATIVE', 'December'),
        ];
    }
1188468
def quarter_boundaries(quarter):
    
    year, quarter = quarter.split('Q')
    year = int(year)
    quarter = int(quarter)
    first_month_of_quarter = 3 * quarter - 2
    last_month_of_quarter = 3 * quarter
    first_day = date(year, first_month_of_quarter, 1)
    last_day = date(year, last_month_of_quarter, monthrange(year, last_month_of_quarter)[1])
    return first_day, last_day
897392
public function getCountPerMonth(Carbon $from, Carbon $until = null, $locale = null, $query = null, $cacheKey = null)
    {
        return $this->getCountPer('Month', $from, $until, $locale, $query, $cacheKey);
    }
227637
def this_quarter():
        
        since = TODAY + delta(day=1)
        while since.month % 3 != 0:
            since -= delta(months=1)
        until = since + delta(months=3)
        return Date(since), Date(until)
1274565
public function getFiscalYears()
  {
    $fiscalYears = array();

    $this->FiscalYear->byOrganization($this->AuthenticationManager->getCurrentUserOrganizationId())->each(function($FiscalYear) use (&$fiscalYears)
    {
      array_push($fiscalYears, $FiscalYear->year);
    });

    return $fiscalYears;
  }
1125461
public static function createFromQuarter($year, $quarter)
	    {
	        $year  = self::validateYear($year);
	        $month = ((self::validateRange($quarter, 1, 4) - 1) * 3) + 1;

	        return self::createFromDuration($year.'-'.sprintf('%02s', $month).'-01', '3 MONTHS');
	    }
764915
public function scopeByYearMonth($query, $year, $month)
	{
		return $query->where(\DB::raw('DATE_FORMAT(published_date, "%Y%m")'), '=', $year.$month);
	}
611289
def quarter(d):
    
    from django_toolkit.datetime_util import quarter as datetime_quarter
    first_date, last_date = datetime_quarter(datetime(d.year, d.month, d.day))
    return first_date.date(), last_date.date()
1033935
public function startOfQuarter()
    {
        $month = ($this->quarter - 1) * static::MONTHS_PER_QUARTER + 1;

        return $this->setDate($this->year, $month, 1)->startOfDay();
    }
222096
public function getMonthNamesNarrow($month = null)
    {
        $calendar = $this->getName();
        // gregorian, generic

        $data = array();
        $calendsFallback = array($calendar, 'gregorian', 'generic');
        foreach ($calendsFallback as $calendar) {
            $data = $this->getRepoReader()->getEntityByPath(
                'dates/calendars/calendar[@type="'.$calendar.'"]/months/monthContext[@type="format"]/monthWidth[@type="abbreviated"]/month'
            );

            if ($data) {
                break;
            }
        }

        $months = array();
        foreach($data as $d) {
            $months[$d['type']] = $d['value'];
        }

        $return = ($month == null) ? $months : false;

        return isset($months[$month]) ? $months[$month] : $return;
    }
324019
public static Date dateReservedQuarter000(int year, int quarter) {
        Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.YEAR, year);
        if (quarter <= 1) {
            calendar.set(Calendar.MONTH, Calendar.JANUARY);
        } else if (quarter == 2) {
            calendar.set(Calendar.MONTH, Calendar.APRIL);
        } else if (quarter == 3) {
            calendar.set(Calendar.MONTH, Calendar.JULY);
        } else {
            calendar.set(Calendar.MONTH, Calendar.OCTOBER);
        }
        return dateReservedMonth000(calendar);
    }
681660
public function getTopReferrersForPeriod($startDate, $endDate, $maxResults)
    {
        $referrerData = [];

        $answer = $this->performQuery($startDate, $endDate, 'ga:pageviews', ['dimensions' => 'ga:fullReferrer', 'sort' => '-ga:pageviews', 'max-results' => $maxResults]);

        if (is_null($answer->rows)) {
            return new Collection([]);
        }

        foreach ($answer->rows as $pageRow) {
            $referrerData[] = ['url' => $pageRow[0], 'pageViews' => $pageRow[1]];
        }

        return new Collection($referrerData);
    }