1 import { normalizeUnits } from '../units/aliases';
3 export function startOf (units) {
4 units = normalizeUnits(units);
5 // the following switch intentionally omits break keywords
6 // to utilize falling through the cases.
31 // weeks are a special case
32 if (units === 'week') {
35 if (units === 'isoWeek') {
39 // quarters are also special
40 if (units === 'quarter') {
41 this.month(Math.floor(this.month() / 3) * 3);
47 export function endOf (units) {
48 units = normalizeUnits(units);
49 if (units === undefined || units === 'millisecond') {
53 // 'date' is an alias for 'day', so it should be considered as such.
54 if (units === 'date') {
58 return this.startOf(units).add(1, (units === 'isoWeek' ? 'week' : units)).subtract(1, 'ms');