Return start and end date of this fiscal year
774125
def this_year():
        
        since = TODAY
        while since.month != 3 or since.day != 1:
            since -= delta(days=1)
        until = since + delta(years=1)
        return Date(since), Date(until)
251449
def _format_dates(self, start, end):
        """"""
        start = self._split_date(start)
        end = self._split_date(end)
        return start, end
630991
def this_year(self):
        
        start_date, end_date = get_date_range_this_year()
        return self.filter(start_time__gte=start_date, start_time__lte=end_date)
845164
def date_from_quarter(base_date, ordinal, year):
    
    interval = 3
    month_start = interval * (ordinal - 1)
    if month_start < 0:
        month_start = 9
    month_end = month_start + interval
    if month_start == 0:
        month_start = 1
    return [
        datetime(year, month_start, 1),
        datetime(year, month_end, calendar.monthrange(year, month_end)[1])
    ]
1321138
def get_year_start(day=None):
    """"""
    day = add_timezone(day or datetime.date.today())
    return day.replace(month=1).replace(day=1)
312397
long yearsUntil(Symmetry010Date end) {
        long startYear = this.prolepticYear * 512L + this.getDayOfYear();
        long endYear = end.prolepticYear * 512L + end.getDayOfYear();
        return (endYear - startYear) / 512L;
    }
586100
def start_of_quarter(year, quarter)
      case quarter
      when QUARTER_1
        start_of_month(year, 1)
      when QUARTER_2
        start_of_month(year, 4)
      when QUARTER_3
        start_of_month(year, 7)
      when QUARTER_4
        start_of_month(year, 10)
      else
        raise "invalid quarter"
      end
    end
1228332
function () {
        var range = this._model.get('range');

        var rg = range;

        if (zrUtil.isArray(rg) && rg.length === 1) {
            rg = rg[0];
        }

        if (/^\d{4}$/.test(rg)) {
            range = [rg + '-01-01', rg + '-12-31'];
        }

        if (/^\d{4}[\/|-]\d{1,2}$/.test(rg)) {

            var start = this.getDateInfo(rg);
            var firstDay = start.date;
            firstDay.setMonth(firstDay.getMonth() + 1);

            var end = this.getNextNDay(firstDay, -1);
            range = [start.formatedDate, end.formatedDate];
        }

        if (/^\d{4}[\/|-]\d{1,2}[\/|-]\d{1,2}$/.test(rg)) {
            range = [rg, rg];
        }

        var tmp = this._getRangeInfo(range);

        if (tmp.start.time > tmp.end.time) {
            range.reverse();
        }

        return range;
    }
1332688
function (year) {
			var daysCount = 0;
			for (var i = 1; i <= 12; i++) {
				daysCount += this.daysInMonth(year, i);
			}
			return daysCount;
		}
1330203
def _yyyymmdd_to_year_fraction(date):
    """"""
    date = str(date)
    if '.' in date:
        date, residual = str(date).split('.')
        residual = float('0.' + residual)
    else:
        residual = 0.0

    date = _datetime.datetime.strptime(date, '%Y%m%d')
    date += _datetime.timedelta(days=residual)

    year = date.year
    year_start = _datetime.datetime(year=year, month=1, day=1)
    next_year_start = _datetime.datetime(year=year + 1, month=1, day=1)
    year_duration = next_year_start - year_start

    year_elapsed = date - year_start
    fraction = year_elapsed / year_duration

    return year + fraction
1213705
def period(argument):
        
        since, until, period = None, None, None
        if "today" in argument:
            since = Date("today")
            until = Date("today")
            until.date += delta(days=1)
            period = "today"
        elif "yesterday" in argument:
            since = Date("yesterday")
            until = Date("yesterday")
            until.date += delta(days=1)
            period = "yesterday"
        elif "year" in argument:
            if "last" in argument:
                since, until = Date.last_year()
                period = "the last fiscal year"
            else:
                since, until = Date.this_year()
                period = "this fiscal year"
        elif "quarter" in argument:
            if "last" in argument:
                since, until = Date.last_quarter()
                period = "the last quarter"
            else:
                since, until = Date.this_quarter()
                period = "this quarter"
        elif "month" in argument:
            if "last" in argument:
                since, until = Date.last_month()
            else:
                since, until = Date.this_month()
            period = since.datetime.strftime("%B")
        else:
            if "last" in argument:
                since, until = Date.last_week()
            else:
                since, until = Date.this_week()
            period = "the week {0}".format(since.datetime.strftime("%V"))
        return since, until, period
646791
def rollforward(self, date):
        """"""
        if self.onOffset(date):
            return date
        else:
            return date + YearBegin(month=self.month)
1366874
function startOfMonth() {
      var result = this.clone();
      result.day = 1;
      result.isDate = true;
      result.hour = 0;
      result.minute = 0;
      result.second = 0;
      return result;
    }
1170819
private static String yearAndQuarter(Calendar cal) {
		return new StringBuilder().append(cal.get(Calendar.YEAR)).append(cal.get(Calendar.MONTH) / 3 + 1).toString();
	}
1371666
function(year) {
        var date = this._validate(year, this.minMonth, this.minDay,
            _exports.local.invalidYear || _exports.regionalOptions[''].invalidYear);
        return (date.year() < 0 ? '-' : '') + pad(Math.abs(date.year()), 4)
    }
1060111
def canceled_during(self, year, month):
		""""""
		return self.canceled().filter(canceled_at__year=year, canceled_at__month=month)
1294305
private Date seasonalDateFromIcs(String icsFileName, String eventSummary, int year) {
    Map<Integer, Date> dates = getDatesFromIcs(icsFileName, eventSummary, year, year);
    return dates.get(year - (eventSummary.equals(Holiday.NEW_YEARS_EVE.getSummary()) ? 1 : 0));
  }