Brought in another asset for Ray's eye form: moment
[openemr.git] / public / assets / moment-2-13-0 / src / lib / moment / start-end-of.js
blobc8a68ac6b9e2d59d109be00b863978f8925ebdb4
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.
7     switch (units) {
8     case 'year':
9         this.month(0);
10         /* falls through */
11     case 'quarter':
12     case 'month':
13         this.date(1);
14         /* falls through */
15     case 'week':
16     case 'isoWeek':
17     case 'day':
18     case 'date':
19         this.hours(0);
20         /* falls through */
21     case 'hour':
22         this.minutes(0);
23         /* falls through */
24     case 'minute':
25         this.seconds(0);
26         /* falls through */
27     case 'second':
28         this.milliseconds(0);
29     }
31     // weeks are a special case
32     if (units === 'week') {
33         this.weekday(0);
34     }
35     if (units === 'isoWeek') {
36         this.isoWeekday(1);
37     }
39     // quarters are also special
40     if (units === 'quarter') {
41         this.month(Math.floor(this.month() / 3) * 3);
42     }
44     return this;
47 export function endOf (units) {
48     units = normalizeUnits(units);
49     if (units === undefined || units === 'millisecond') {
50         return this;
51     }
53     // 'date' is an alias for 'day', so it should be considered as such.
54     if (units === 'date') {
55         units = 'day';
56     }
58     return this.startOf(units).add(1, (units === 'isoWeek' ? 'week' : units)).subtract(1, 'ms');