-import {normalizeUnits} from '../units/aliases';
+import { normalizeUnits } from '../units/aliases';
-export function startOf(units) {
+export function startOf (units) {
units = normalizeUnits(units);
// the following switch intentionally omits break keywords
// to utilize falling through the cases.
switch (units) {
case 'year':
this.month(0);
- /* falls through */
+ /* falls through */
case 'quarter':
case 'month':
this.date(1);
- /* falls through */
+ /* falls through */
case 'week':
case 'isoWeek':
case 'day':
case 'date':
this.hours(0);
- /* falls through */
+ /* falls through */
case 'hour':
this.minutes(0);
- /* falls through */
+ /* falls through */
case 'minute':
this.seconds(0);
- /* falls through */
+ /* falls through */
case 'second':
this.milliseconds(0);
}
return this;
}
-export function endOf(units) {
+export function endOf (units) {
units = normalizeUnits(units);
if (units === undefined || units === 'millisecond') {
return this;
units = 'day';
}
- switch (units) {
- case 'day':
- var endOfDay = this.startOf(units).add(1, units).subtract(1, 'ms');
- endOfDay.hours(23);
- endOfDay.minutes(59);
- endOfDay.seconds(59);
- endOfDay.milliseconds(999);
- return endOfDay;
- default:
- return this.startOf(units).add(1, (units === 'isoWeek' ? 'week' : units)).subtract(1, 'ms');
- }
+ return this.startOf(units).add(1, (units === 'isoWeek' ? 'week' : units)).subtract(1, 'ms');
}