Commit 3c78d614c258bea9df399445055807660446ea20
1 parent
91116bd7
Introduce week intervals (Mon - Sun) and (Sun - Sat)
Showing
2 changed files
with
40 additions
and
4 deletions
@@ -136,13 +136,16 @@ export enum QuickTimeInterval { | @@ -136,13 +136,16 @@ export enum QuickTimeInterval { | ||
136 | DAY_BEFORE_YESTERDAY = 'DAY_BEFORE_YESTERDAY', | 136 | DAY_BEFORE_YESTERDAY = 'DAY_BEFORE_YESTERDAY', |
137 | THIS_DAY_LAST_WEEK = 'THIS_DAY_LAST_WEEK', | 137 | THIS_DAY_LAST_WEEK = 'THIS_DAY_LAST_WEEK', |
138 | PREVIOUS_WEEK = 'PREVIOUS_WEEK', | 138 | PREVIOUS_WEEK = 'PREVIOUS_WEEK', |
139 | + PREVIOUS_WEEK_ISO = 'PREVIOUS_WEEK_ISO', | ||
139 | PREVIOUS_MONTH = 'PREVIOUS_MONTH', | 140 | PREVIOUS_MONTH = 'PREVIOUS_MONTH', |
140 | PREVIOUS_YEAR = 'PREVIOUS_YEAR', | 141 | PREVIOUS_YEAR = 'PREVIOUS_YEAR', |
141 | CURRENT_HOUR = 'CURRENT_HOUR', | 142 | CURRENT_HOUR = 'CURRENT_HOUR', |
142 | CURRENT_DAY = 'CURRENT_DAY', | 143 | CURRENT_DAY = 'CURRENT_DAY', |
143 | CURRENT_DAY_SO_FAR = 'CURRENT_DAY_SO_FAR', | 144 | CURRENT_DAY_SO_FAR = 'CURRENT_DAY_SO_FAR', |
144 | CURRENT_WEEK = 'CURRENT_WEEK', | 145 | CURRENT_WEEK = 'CURRENT_WEEK', |
145 | - CURRENT_WEEK_SO_FAR = 'CURRENT_WEEK_SO_WAR', | 146 | + CURRENT_WEEK_ISO = 'CURRENT_WEEK_ISO', |
147 | + CURRENT_WEEK_SO_FAR = 'CURRENT_WEEK_SO_FAR', | ||
148 | + CURRENT_WEEK_ISO_SO_FAR = 'CURRENT_WEEK_ISO_SO_FAR', | ||
146 | CURRENT_MONTH = 'CURRENT_MONTH', | 149 | CURRENT_MONTH = 'CURRENT_MONTH', |
147 | CURRENT_MONTH_SO_FAR = 'CURRENT_MONTH_SO_FAR', | 150 | CURRENT_MONTH_SO_FAR = 'CURRENT_MONTH_SO_FAR', |
148 | CURRENT_YEAR = 'CURRENT_YEAR', | 151 | CURRENT_YEAR = 'CURRENT_YEAR', |
@@ -154,13 +157,16 @@ export const QuickTimeIntervalTranslationMap = new Map<QuickTimeInterval, string | @@ -154,13 +157,16 @@ export const QuickTimeIntervalTranslationMap = new Map<QuickTimeInterval, string | ||
154 | [QuickTimeInterval.DAY_BEFORE_YESTERDAY, 'timeinterval.predefined.day-before-yesterday'], | 157 | [QuickTimeInterval.DAY_BEFORE_YESTERDAY, 'timeinterval.predefined.day-before-yesterday'], |
155 | [QuickTimeInterval.THIS_DAY_LAST_WEEK, 'timeinterval.predefined.this-day-last-week'], | 158 | [QuickTimeInterval.THIS_DAY_LAST_WEEK, 'timeinterval.predefined.this-day-last-week'], |
156 | [QuickTimeInterval.PREVIOUS_WEEK, 'timeinterval.predefined.previous-week'], | 159 | [QuickTimeInterval.PREVIOUS_WEEK, 'timeinterval.predefined.previous-week'], |
160 | + [QuickTimeInterval.PREVIOUS_WEEK_ISO, 'timeinterval.predefined.previous-week-iso'], | ||
157 | [QuickTimeInterval.PREVIOUS_MONTH, 'timeinterval.predefined.previous-month'], | 161 | [QuickTimeInterval.PREVIOUS_MONTH, 'timeinterval.predefined.previous-month'], |
158 | [QuickTimeInterval.PREVIOUS_YEAR, 'timeinterval.predefined.previous-year'], | 162 | [QuickTimeInterval.PREVIOUS_YEAR, 'timeinterval.predefined.previous-year'], |
159 | [QuickTimeInterval.CURRENT_HOUR, 'timeinterval.predefined.current-hour'], | 163 | [QuickTimeInterval.CURRENT_HOUR, 'timeinterval.predefined.current-hour'], |
160 | [QuickTimeInterval.CURRENT_DAY, 'timeinterval.predefined.current-day'], | 164 | [QuickTimeInterval.CURRENT_DAY, 'timeinterval.predefined.current-day'], |
161 | [QuickTimeInterval.CURRENT_DAY_SO_FAR, 'timeinterval.predefined.current-day-so-far'], | 165 | [QuickTimeInterval.CURRENT_DAY_SO_FAR, 'timeinterval.predefined.current-day-so-far'], |
162 | [QuickTimeInterval.CURRENT_WEEK, 'timeinterval.predefined.current-week'], | 166 | [QuickTimeInterval.CURRENT_WEEK, 'timeinterval.predefined.current-week'], |
167 | + [QuickTimeInterval.CURRENT_WEEK_ISO, 'timeinterval.predefined.current-week-iso'], | ||
163 | [QuickTimeInterval.CURRENT_WEEK_SO_FAR, 'timeinterval.predefined.current-week-so-far'], | 168 | [QuickTimeInterval.CURRENT_WEEK_SO_FAR, 'timeinterval.predefined.current-week-so-far'], |
169 | + [QuickTimeInterval.CURRENT_WEEK_ISO_SO_FAR, 'timeinterval.predefined.current-week-iso-so-far'], | ||
164 | [QuickTimeInterval.CURRENT_MONTH, 'timeinterval.predefined.current-month'], | 170 | [QuickTimeInterval.CURRENT_MONTH, 'timeinterval.predefined.current-month'], |
165 | [QuickTimeInterval.CURRENT_MONTH_SO_FAR, 'timeinterval.predefined.current-month-so-far'], | 171 | [QuickTimeInterval.CURRENT_MONTH_SO_FAR, 'timeinterval.predefined.current-month-so-far'], |
166 | [QuickTimeInterval.CURRENT_YEAR, 'timeinterval.predefined.current-year'], | 172 | [QuickTimeInterval.CURRENT_YEAR, 'timeinterval.predefined.current-year'], |
@@ -453,7 +459,9 @@ function getSubscriptionRealtimeWindowFromTimeInterval(interval: QuickTimeInterv | @@ -453,7 +459,9 @@ function getSubscriptionRealtimeWindowFromTimeInterval(interval: QuickTimeInterv | ||
453 | case QuickTimeInterval.CURRENT_DAY_SO_FAR: | 459 | case QuickTimeInterval.CURRENT_DAY_SO_FAR: |
454 | return DAY; | 460 | return DAY; |
455 | case QuickTimeInterval.CURRENT_WEEK: | 461 | case QuickTimeInterval.CURRENT_WEEK: |
462 | + case QuickTimeInterval.CURRENT_WEEK_ISO: | ||
456 | case QuickTimeInterval.CURRENT_WEEK_SO_FAR: | 463 | case QuickTimeInterval.CURRENT_WEEK_SO_FAR: |
464 | + case QuickTimeInterval.CURRENT_WEEK_ISO_SO_FAR: | ||
457 | return WEEK; | 465 | return WEEK; |
458 | case QuickTimeInterval.CURRENT_MONTH: | 466 | case QuickTimeInterval.CURRENT_MONTH: |
459 | case QuickTimeInterval.CURRENT_MONTH_SO_FAR: | 467 | case QuickTimeInterval.CURRENT_MONTH_SO_FAR: |
@@ -479,6 +487,9 @@ export function calculateIntervalEndTime(interval: QuickTimeInterval, currentDat | @@ -479,6 +487,9 @@ export function calculateIntervalEndTime(interval: QuickTimeInterval, currentDat | ||
479 | case QuickTimeInterval.PREVIOUS_WEEK: | 487 | case QuickTimeInterval.PREVIOUS_WEEK: |
480 | currentDate.subtract(1, 'weeks'); | 488 | currentDate.subtract(1, 'weeks'); |
481 | return currentDate.endOf('week').valueOf(); | 489 | return currentDate.endOf('week').valueOf(); |
490 | + case QuickTimeInterval.PREVIOUS_WEEK_ISO: | ||
491 | + currentDate.subtract(1, 'weeks'); | ||
492 | + return currentDate.endOf('isoWeek').valueOf(); | ||
482 | case QuickTimeInterval.PREVIOUS_MONTH: | 493 | case QuickTimeInterval.PREVIOUS_MONTH: |
483 | currentDate.subtract(1, 'months'); | 494 | currentDate.subtract(1, 'months'); |
484 | return currentDate.endOf('month').valueOf(); | 495 | return currentDate.endOf('month').valueOf(); |
@@ -491,12 +502,15 @@ export function calculateIntervalEndTime(interval: QuickTimeInterval, currentDat | @@ -491,12 +502,15 @@ export function calculateIntervalEndTime(interval: QuickTimeInterval, currentDat | ||
491 | return currentDate.endOf('day').valueOf(); | 502 | return currentDate.endOf('day').valueOf(); |
492 | case QuickTimeInterval.CURRENT_WEEK: | 503 | case QuickTimeInterval.CURRENT_WEEK: |
493 | return currentDate.endOf('week').valueOf(); | 504 | return currentDate.endOf('week').valueOf(); |
505 | + case QuickTimeInterval.CURRENT_WEEK_ISO: | ||
506 | + return currentDate.endOf('isoWeek').valueOf(); | ||
494 | case QuickTimeInterval.CURRENT_MONTH: | 507 | case QuickTimeInterval.CURRENT_MONTH: |
495 | return currentDate.endOf('month').valueOf(); | 508 | return currentDate.endOf('month').valueOf(); |
496 | case QuickTimeInterval.CURRENT_YEAR: | 509 | case QuickTimeInterval.CURRENT_YEAR: |
497 | return currentDate.endOf('year').valueOf(); | 510 | return currentDate.endOf('year').valueOf(); |
498 | case QuickTimeInterval.CURRENT_DAY_SO_FAR: | 511 | case QuickTimeInterval.CURRENT_DAY_SO_FAR: |
499 | case QuickTimeInterval.CURRENT_WEEK_SO_FAR: | 512 | case QuickTimeInterval.CURRENT_WEEK_SO_FAR: |
513 | + case QuickTimeInterval.CURRENT_WEEK_ISO_SO_FAR: | ||
500 | case QuickTimeInterval.CURRENT_MONTH_SO_FAR: | 514 | case QuickTimeInterval.CURRENT_MONTH_SO_FAR: |
501 | case QuickTimeInterval.CURRENT_YEAR_SO_FAR: | 515 | case QuickTimeInterval.CURRENT_YEAR_SO_FAR: |
502 | return currentDate.valueOf(); | 516 | return currentDate.valueOf(); |
@@ -518,6 +532,9 @@ export function calculateIntervalStartTime(interval: QuickTimeInterval, currentD | @@ -518,6 +532,9 @@ export function calculateIntervalStartTime(interval: QuickTimeInterval, currentD | ||
518 | case QuickTimeInterval.PREVIOUS_WEEK: | 532 | case QuickTimeInterval.PREVIOUS_WEEK: |
519 | currentDate.subtract(1, 'weeks'); | 533 | currentDate.subtract(1, 'weeks'); |
520 | return currentDate.startOf('week').valueOf(); | 534 | return currentDate.startOf('week').valueOf(); |
535 | + case QuickTimeInterval.PREVIOUS_WEEK_ISO: | ||
536 | + currentDate.subtract(1, 'weeks'); | ||
537 | + return currentDate.startOf('isoWeek').valueOf(); | ||
521 | case QuickTimeInterval.PREVIOUS_MONTH: | 538 | case QuickTimeInterval.PREVIOUS_MONTH: |
522 | currentDate.subtract(1, 'months'); | 539 | currentDate.subtract(1, 'months'); |
523 | return currentDate.startOf('month').valueOf(); | 540 | return currentDate.startOf('month').valueOf(); |
@@ -532,6 +549,9 @@ export function calculateIntervalStartTime(interval: QuickTimeInterval, currentD | @@ -532,6 +549,9 @@ export function calculateIntervalStartTime(interval: QuickTimeInterval, currentD | ||
532 | case QuickTimeInterval.CURRENT_WEEK: | 549 | case QuickTimeInterval.CURRENT_WEEK: |
533 | case QuickTimeInterval.CURRENT_WEEK_SO_FAR: | 550 | case QuickTimeInterval.CURRENT_WEEK_SO_FAR: |
534 | return currentDate.startOf('week').valueOf(); | 551 | return currentDate.startOf('week').valueOf(); |
552 | + case QuickTimeInterval.CURRENT_WEEK_ISO: | ||
553 | + case QuickTimeInterval.CURRENT_WEEK_ISO_SO_FAR: | ||
554 | + return currentDate.startOf('isoWeek').valueOf(); | ||
535 | case QuickTimeInterval.CURRENT_MONTH: | 555 | case QuickTimeInterval.CURRENT_MONTH: |
536 | case QuickTimeInterval.CURRENT_MONTH_SO_FAR: | 556 | case QuickTimeInterval.CURRENT_MONTH_SO_FAR: |
537 | return currentDate.startOf('month').valueOf(); | 557 | return currentDate.startOf('month').valueOf(); |
@@ -552,8 +572,11 @@ export function quickTimeIntervalPeriod(interval: QuickTimeInterval): number { | @@ -552,8 +572,11 @@ export function quickTimeIntervalPeriod(interval: QuickTimeInterval): number { | ||
552 | case QuickTimeInterval.CURRENT_DAY_SO_FAR: | 572 | case QuickTimeInterval.CURRENT_DAY_SO_FAR: |
553 | return DAY; | 573 | return DAY; |
554 | case QuickTimeInterval.PREVIOUS_WEEK: | 574 | case QuickTimeInterval.PREVIOUS_WEEK: |
575 | + case QuickTimeInterval.PREVIOUS_WEEK_ISO: | ||
555 | case QuickTimeInterval.CURRENT_WEEK: | 576 | case QuickTimeInterval.CURRENT_WEEK: |
577 | + case QuickTimeInterval.CURRENT_WEEK_ISO: | ||
556 | case QuickTimeInterval.CURRENT_WEEK_SO_FAR: | 578 | case QuickTimeInterval.CURRENT_WEEK_SO_FAR: |
579 | + case QuickTimeInterval.CURRENT_WEEK_ISO_SO_FAR: | ||
557 | return WEEK; | 580 | return WEEK; |
558 | case QuickTimeInterval.PREVIOUS_MONTH: | 581 | case QuickTimeInterval.PREVIOUS_MONTH: |
559 | case QuickTimeInterval.CURRENT_MONTH: | 582 | case QuickTimeInterval.CURRENT_MONTH: |
@@ -583,6 +606,11 @@ export function calculateIntervalComparisonStartTime(interval: QuickTimeInterval | @@ -583,6 +606,11 @@ export function calculateIntervalComparisonStartTime(interval: QuickTimeInterval | ||
583 | case QuickTimeInterval.CURRENT_WEEK_SO_FAR: | 606 | case QuickTimeInterval.CURRENT_WEEK_SO_FAR: |
584 | currentDate.subtract(1, 'weeks'); | 607 | currentDate.subtract(1, 'weeks'); |
585 | return currentDate.startOf('week').valueOf(); | 608 | return currentDate.startOf('week').valueOf(); |
609 | + case QuickTimeInterval.PREVIOUS_WEEK_ISO: | ||
610 | + case QuickTimeInterval.CURRENT_WEEK_ISO: | ||
611 | + case QuickTimeInterval.CURRENT_WEEK_ISO_SO_FAR: | ||
612 | + currentDate.subtract(1, 'weeks'); | ||
613 | + return currentDate.startOf('isoWeek').valueOf(); | ||
586 | case QuickTimeInterval.PREVIOUS_MONTH: | 614 | case QuickTimeInterval.PREVIOUS_MONTH: |
587 | case QuickTimeInterval.CURRENT_MONTH: | 615 | case QuickTimeInterval.CURRENT_MONTH: |
588 | case QuickTimeInterval.CURRENT_MONTH_SO_FAR: | 616 | case QuickTimeInterval.CURRENT_MONTH_SO_FAR: |
@@ -616,7 +644,12 @@ export function calculateIntervalComparisonEndTime(interval: QuickTimeInterval, | @@ -616,7 +644,12 @@ export function calculateIntervalComparisonEndTime(interval: QuickTimeInterval, | ||
616 | case QuickTimeInterval.CURRENT_WEEK: | 644 | case QuickTimeInterval.CURRENT_WEEK: |
617 | currentDate.subtract(1, 'weeks'); | 645 | currentDate.subtract(1, 'weeks'); |
618 | return currentDate.endOf('week').valueOf(); | 646 | return currentDate.endOf('week').valueOf(); |
647 | + case QuickTimeInterval.PREVIOUS_WEEK_ISO: | ||
648 | + case QuickTimeInterval.CURRENT_WEEK_ISO: | ||
649 | + currentDate.subtract(1, 'weeks'); | ||
650 | + return currentDate.endOf('isoWeek').valueOf(); | ||
619 | case QuickTimeInterval.CURRENT_WEEK_SO_FAR: | 651 | case QuickTimeInterval.CURRENT_WEEK_SO_FAR: |
652 | + case QuickTimeInterval.CURRENT_WEEK_ISO_SO_FAR: | ||
620 | return currentDate.subtract(1, 'week').valueOf(); | 653 | return currentDate.subtract(1, 'week').valueOf(); |
621 | case QuickTimeInterval.PREVIOUS_MONTH: | 654 | case QuickTimeInterval.PREVIOUS_MONTH: |
622 | case QuickTimeInterval.CURRENT_MONTH: | 655 | case QuickTimeInterval.CURRENT_MONTH: |
@@ -2131,14 +2131,17 @@ | @@ -2131,14 +2131,17 @@ | ||
2131 | "yesterday": "Yesterday", | 2131 | "yesterday": "Yesterday", |
2132 | "day-before-yesterday": "Day before yesterday", | 2132 | "day-before-yesterday": "Day before yesterday", |
2133 | "this-day-last-week": "This day last week", | 2133 | "this-day-last-week": "This day last week", |
2134 | - "previous-week": "Previous week", | 2134 | + "previous-week": "Previous week (Sun - Sat)", |
2135 | + "previous-week-iso": "Previous week (Mon - Sun)", | ||
2135 | "previous-month": "Previous month", | 2136 | "previous-month": "Previous month", |
2136 | "previous-year": "Previous year", | 2137 | "previous-year": "Previous year", |
2137 | "current-hour": "Current hour", | 2138 | "current-hour": "Current hour", |
2138 | "current-day": "Current day", | 2139 | "current-day": "Current day", |
2139 | "current-day-so-far": "Current day so far", | 2140 | "current-day-so-far": "Current day so far", |
2140 | - "current-week": "Current week", | ||
2141 | - "current-week-so-far": "Current week so far", | 2141 | + "current-week": "Current week (Sun - Sat)", |
2142 | + "current-week-iso": "Current week (Mon - Sun)", | ||
2143 | + "current-week-so-far": "Current week so far (Sun - Sat)", | ||
2144 | + "current-week-iso-so-far": "Current week so far (Mon - Sun)", | ||
2142 | "current-month": "Current month", | 2145 | "current-month": "Current month", |
2143 | "current-month-so-far": "Current month so far", | 2146 | "current-month-so-far": "Current month so far", |
2144 | "current-year": "Current year", | 2147 | "current-year": "Current year", |