summaryrefslogtreecommitdiff
path: root/bin/wiki/ImportarDesdeURL/node_modules/moment/src/lib/moment/start-end-of.js
diff options
context:
space:
mode:
Diffstat (limited to 'bin/wiki/ImportarDesdeURL/node_modules/moment/src/lib/moment/start-end-of.js')
-rw-r--r--bin/wiki/ImportarDesdeURL/node_modules/moment/src/lib/moment/start-end-of.js59
1 files changed, 59 insertions, 0 deletions
diff --git a/bin/wiki/ImportarDesdeURL/node_modules/moment/src/lib/moment/start-end-of.js b/bin/wiki/ImportarDesdeURL/node_modules/moment/src/lib/moment/start-end-of.js
new file mode 100644
index 00000000..02f98247
--- /dev/null
+++ b/bin/wiki/ImportarDesdeURL/node_modules/moment/src/lib/moment/start-end-of.js
@@ -0,0 +1,59 @@
+import { normalizeUnits } from '../units/aliases';
+
+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 */
+ case 'quarter':
+ case 'month':
+ this.date(1);
+ /* falls through */
+ case 'week':
+ case 'isoWeek':
+ case 'day':
+ case 'date':
+ this.hours(0);
+ /* falls through */
+ case 'hour':
+ this.minutes(0);
+ /* falls through */
+ case 'minute':
+ this.seconds(0);
+ /* falls through */
+ case 'second':
+ this.milliseconds(0);
+ }
+
+ // weeks are a special case
+ if (units === 'week') {
+ this.weekday(0);
+ }
+ if (units === 'isoWeek') {
+ this.isoWeekday(1);
+ }
+
+ // quarters are also special
+ if (units === 'quarter') {
+ this.month(Math.floor(this.month() / 3) * 3);
+ }
+
+ return this;
+}
+
+export function endOf (units) {
+ units = normalizeUnits(units);
+ if (units === undefined || units === 'millisecond') {
+ return this;
+ }
+
+ // 'date' is an alias for 'day', so it should be considered as such.
+ if (units === 'date') {
+ units = 'day';
+ }
+
+ return this.startOf(units).add(1, (units === 'isoWeek' ? 'week' : units)).subtract(1, 'ms');
+}