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

Function startOf

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

Source from the content-addressed store, hash-verified

4073 }
4074
4075 function startOf(units) {
4076 var time, startOfDate;
4077 units = normalizeUnits(units);
4078 if (units === undefined || units === 'millisecond' || !this.isValid()) {
4079 return this;
4080 }
4081
4082 startOfDate = this._isUTC ? utcStartOfDate : localStartOfDate;
4083
4084 switch (units) {
4085 case 'year':
4086 time = startOfDate(this.year(), 0, 1);
4087 break;
4088 case 'quarter':
4089 time = startOfDate(
4090 this.year(),
4091 this.month() - (this.month() % 3),
4092 1
4093 );
4094 break;
4095 case 'month':
4096 time = startOfDate(this.year(), this.month(), 1);
4097 break;
4098 case 'week':
4099 time = startOfDate(
4100 this.year(),
4101 this.month(),
4102 this.date() - this.weekday()
4103 );
4104 break;
4105 case 'isoWeek':
4106 time = startOfDate(
4107 this.year(),
4108 this.month(),
4109 this.date() - (this.isoWeekday() - 1)
4110 );
4111 break;
4112 case 'day':
4113 case 'date':
4114 time = startOfDate(this.year(), this.month(), this.date());
4115 break;
4116 case 'hour':
4117 time = this._d.valueOf();
4118 time -= mod$1(
4119 time + (this._isUTC ? 0 : this.utcOffset() * MS_PER_MINUTE),
4120 MS_PER_HOUR
4121 );
4122 break;
4123 case 'minute':
4124 time = this._d.valueOf();
4125 time -= mod$1(time, MS_PER_MINUTE);
4126 break;
4127 case 'second':
4128 time = this._d.valueOf();
4129 time -= mod$1(time, MS_PER_SECOND);
4130 break;
4131 }
4132

Callers

nothing calls this directly

Calls 2

normalizeUnitsFunction · 0.85
mod$1Function · 0.85

Tested by

no test coverage detected