MCPcopy Create free account
hub / github.com/scottrogowski/code2flow / endOf

Function endOf

tests/test_code/js/moment/moment.js:4138–4205  ·  view source on GitHub ↗
(units)

Source from the content-addressed store, hash-verified

4136 }
4137
4138 function endOf(units) {
4139 var time, startOfDate;
4140 units = normalizeUnits(units);
4141 if (units === undefined || units === 'millisecond' || !this.isValid()) {
4142 return this;
4143 }
4144
4145 startOfDate = this._isUTC ? utcStartOfDate : localStartOfDate;
4146
4147 switch (units) {
4148 case 'year':
4149 time = startOfDate(this.year() + 1, 0, 1) - 1;
4150 break;
4151 case 'quarter':
4152 time =
4153 startOfDate(
4154 this.year(),
4155 this.month() - (this.month() % 3) + 3,
4156 1
4157 ) - 1;
4158 break;
4159 case 'month':
4160 time = startOfDate(this.year(), this.month() + 1, 1) - 1;
4161 break;
4162 case 'week':
4163 time =
4164 startOfDate(
4165 this.year(),
4166 this.month(),
4167 this.date() - this.weekday() + 7
4168 ) - 1;
4169 break;
4170 case 'isoWeek':
4171 time =
4172 startOfDate(
4173 this.year(),
4174 this.month(),
4175 this.date() - (this.isoWeekday() - 1) + 7
4176 ) - 1;
4177 break;
4178 case 'day':
4179 case 'date':
4180 time = startOfDate(this.year(), this.month(), this.date() + 1) - 1;
4181 break;
4182 case 'hour':
4183 time = this._d.valueOf();
4184 time +=
4185 MS_PER_HOUR -
4186 mod$1(
4187 time + (this._isUTC ? 0 : this.utcOffset() * MS_PER_MINUTE),
4188 MS_PER_HOUR
4189 ) -
4190 1;
4191 break;
4192 case 'minute':
4193 time = this._d.valueOf();
4194 time += MS_PER_MINUTE - mod$1(time, MS_PER_MINUTE) - 1;
4195 break;

Callers

nothing calls this directly

Calls 2

normalizeUnitsFunction · 0.85
mod$1Function · 0.85

Tested by

no test coverage detected