-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show gateway status for whole time period (#101)
* Show gateway status for whole time period * Comment gateway status
- Loading branch information
1 parent
8ccca2f
commit d531172
Showing
4 changed files
with
72 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,22 @@ | ||
import * as moment from 'moment'; | ||
|
||
export enum GatewayStatusInterval { | ||
DAY = 'DAY', | ||
WEEK = 'WEEK', | ||
MONTH = 'MONTH', | ||
} | ||
|
||
export const gatewayStatusIntervalToDate = ( | ||
interval: GatewayStatusInterval | ||
): Date => { | ||
const now = new Date(); | ||
|
||
switch (interval) { | ||
case GatewayStatusInterval.WEEK: | ||
return moment(now).subtract(7, 'days').toDate(); | ||
case GatewayStatusInterval.MONTH: | ||
return moment(now).subtract(30, 'days').toDate(); | ||
default: | ||
return moment(now).subtract(1, 'days').toDate(); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters