| 192 | } |
| 193 | |
| 194 | $set(units, int) { // private set |
| 195 | const unit = Utils.p(units) |
| 196 | const utcPad = `set${this.$u ? 'UTC' : ''}` |
| 197 | const name = { |
| 198 | [C.D]: `${utcPad}Date`, |
| 199 | [C.DATE]: `${utcPad}Date`, |
| 200 | [C.M]: `${utcPad}Month`, |
| 201 | [C.Y]: `${utcPad}FullYear`, |
| 202 | [C.H]: `${utcPad}Hours`, |
| 203 | [C.MIN]: `${utcPad}Minutes`, |
| 204 | [C.S]: `${utcPad}Seconds`, |
| 205 | [C.MS]: `${utcPad}Milliseconds` |
| 206 | }[unit] |
| 207 | const arg = unit === C.D ? this.$D + (int - this.$W) : int |
| 208 | |
| 209 | if (unit === C.M || unit === C.Y) { |
| 210 | // clone is for badMutable plugin |
| 211 | const date = this.clone().set(C.DATE, 1) |
| 212 | date.$d[name](arg) |
| 213 | date.init() |
| 214 | this.$d = date.set(C.DATE, Math.min(this.$D, date.daysInMonth())).$d |
| 215 | } else if (name) this.$d[name](arg) |
| 216 | |
| 217 | this.init() |
| 218 | return this |
| 219 | } |
| 220 | |
| 221 | set(string, int) { |
| 222 | return this.clone().$set(string, int) |