diff --git a/src/lib/moment/start-end-of.js b/src/lib/moment/start-end-of.js index 02f982479a..36674ccc51 100644 --- a/src/lib/moment/start-end-of.js +++ b/src/lib/moment/start-end-of.js @@ -1,29 +1,29 @@ -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); } @@ -44,7 +44,7 @@ export function startOf (units) { return this; } -export function endOf (units) { +export function endOf(units) { units = normalizeUnits(units); if (units === undefined || units === 'millisecond') { return this; @@ -55,5 +55,15 @@ export function endOf (units) { units = 'day'; } - return this.startOf(units).add(1, (units === 'isoWeek' ? 'week' : units)).subtract(1, 'ms'); + 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'); + } }