MCPcopy Create free account
hub / github.com/APIParkLab/APIPark / getTime

Function getTime

frontend/packages/dashboard/src/utils/dashboard.ts:4–37  ·  view source on GitHub ↗
(
  timeButton: string,
  datePickerValue: RangeValue | [],
  init?: boolean
)

Source from the content-addressed store, hash-verified

2import { $t } from '@common/locales'
3
4export function getTime(
5 timeButton: string,
6 datePickerValue: RangeValue | [],
7 init?: boolean
8): { startTime: number; endTime: number } {
9 const currentSecond = new Date().getTime() // 当前毫秒数时间戳
10 let currentMin = currentSecond - (currentSecond % (60 * 1000)) // 当前分钟数时间戳
11 let startMin = currentMin - 60 * 60 * 1000
12 if (!init && timeButton) {
13 switch (timeButton) {
14 case 'hour': {
15 startMin = currentMin - 60 * 60 * 1000
16 break
17 }
18 case 'day': {
19 startMin = currentMin - 24 * 60 * 60 * 1000
20 break
21 }
22 case 'threeDays': {
23 startMin = new Date(new Date().setHours(0, 0, 0, 0)).getTime() - 2 * 24 * 60 * 60 * 1000
24 break
25 }
26 case 'sevenDays': {
27 startMin = new Date(new Date().setHours(0, 0, 0, 0)).getTime() - 6 * 24 * 60 * 60 * 1000
28 break
29 }
30 }
31 } else if (datePickerValue?.length === 2) {
32 startMin = datePickerValue[0]!.startOf('day').unix()
33 currentMin = datePickerValue[1]!.endOf('day').unix()
34 }
35
36 return { startTime: startMin / 1000, endTime: currentMin / 1000 }
37}
38
39export function getTimeUnit(timeInterval: string): string {
40 let timeUnit = ''

Callers 15

ServiceLogsFunction · 0.90
requestApisFunction · 0.90
ServiceOverviewFunction · 0.90
getMonitorDataFunction · 0.90
getMonitorDataFunction · 0.90
getAppTableListFunction · 0.90
exportDataFunction · 0.90
getMonitorDataFunction · 0.90
getAppTableListFunction · 0.90
exportDataFunction · 0.90
getMonitorDataFunction · 0.90
getApiTableListFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected