Skip to content

Commit f4e0f5c

Browse files
authored
Fix date calculation in examples (#837)
The constructor takes ms not seconds.
1 parent 97ebd2c commit f4e0f5c

File tree

52 files changed

+88
-88
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+88
-88
lines changed

.generator/conftest.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,12 @@ def unique(request):
140140
"timestamp": "Math.round({sret}.getTime() / 1000)",
141141
"isoformat": "{sret}",
142142
"units": {
143-
"s": "new Date(new Date().getTime() / 1000 + {num})",
144-
"m": "new Date(new Date().getTime() / 1000 + {num}*60)",
145-
"h": "new Date(new Date().getTime() / 1000 + {num}*3600)",
146-
"d": "new Date(new Date().getTime() / 1000 + {num}*86400)",
147-
"M": "new Date(new Date().getTime() / 1000 + {num}*86400*30)",
148-
"y": "new Date(new Date().getTime() / 1000 + {num}*86400*365)",
143+
"s": "new Date(new Date().getTime() + {num}*1000)",
144+
"m": "new Date(new Date().getTime() + {num}*60*1000)",
145+
"h": "new Date(new Date().getTime() + {num}*3600*1000)",
146+
"d": "new Date(new Date().getTime() + {num}*86400*1000)",
147+
"M": "new Date(new Date().getTime() + {num}*86400*30*1000)",
148+
"y": "new Date(new Date().getTime() + {num}*86400*365*1000)",
149149
},
150150
}
151151

examples/v1/downtimes/CreateDowntime.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const params: v1.DowntimesApiCreateDowntimeRequest = {
1818
period: 1,
1919
weekDays: ["Mon", "Tue", "Wed", "Thu", "Fri"],
2020
untilDate: Math.round(
21-
new Date(new Date().getTime() / 1000 + 21 * 86400).getTime() / 1000
21+
new Date(new Date().getTime() + 21 * 86400 * 1000).getTime() / 1000
2222
),
2323
},
2424
},

examples/v1/downtimes/CreateDowntime_1393233946.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const params: v1.DowntimesApiCreateDowntimeRequest = {
1919
scope: ["*"],
2020
start: Math.round(new Date().getTime() / 1000),
2121
end: Math.round(
22-
new Date(new Date().getTime() / 1000 + 1 * 3600).getTime() / 1000
22+
new Date(new Date().getTime() + 1 * 3600 * 1000).getTime() / 1000
2323
),
2424
timezone: "Etc/UTC",
2525
monitorTags: ["tag0"],

examples/v1/downtimes/CreateDowntime_2908359488.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ const params: v1.DowntimesApiCreateDowntimeRequest = {
1414
period: 1,
1515
type: "weeks",
1616
untilDate: Math.round(
17-
new Date(new Date().getTime() / 1000 + 21 * 86400).getTime() / 1000
17+
new Date(new Date().getTime() + 21 * 86400 * 1000).getTime() / 1000
1818
),
1919
weekDays: ["Mon", "Tue", "Wed", "Thu", "Fri"],
2020
},
2121
scope: ["*"],
2222
start: Math.round(new Date().getTime() / 1000),
2323
end: Math.round(
24-
new Date(new Date().getTime() / 1000 + 1 * 3600).getTime() / 1000
24+
new Date(new Date().getTime() + 1 * 3600 * 1000).getTime() / 1000
2525
),
2626
timezone: "Etc/UTC",
2727
muteFirstRecoveryNotification: true,

examples/v1/downtimes/CreateDowntime_3059354445.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const params: v1.DowntimesApiCreateDowntimeRequest = {
1717
scope: ["*"],
1818
start: Math.round(new Date().getTime() / 1000),
1919
end: Math.round(
20-
new Date(new Date().getTime() / 1000 + 1 * 3600).getTime() / 1000
20+
new Date(new Date().getTime() + 1 * 3600 * 1000).getTime() / 1000
2121
),
2222
timezone: "Etc/UTC",
2323
muteFirstRecoveryNotification: true,

examples/v1/logs/ListLogs_235998668.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const params: v1.LogsApiListLogsRequest = {
1313
query: "host:Test*",
1414
sort: "asc",
1515
time: {
16-
from: new Date(new Date().getTime() / 1000 + -1 * 3600),
16+
from: new Date(new Date().getTime() + -1 * 3600 * 1000),
1717
timezone: "Europe/Paris",
1818
to: new Date(),
1919
},

examples/v1/metrics/QueryMetrics.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const apiInstance = new v1.MetricsApi(configuration);
99

1010
const params: v1.MetricsApiQueryMetricsRequest = {
1111
from: Math.round(
12-
new Date(new Date().getTime() / 1000 + -1 * 86400).getTime() / 1000
12+
new Date(new Date().getTime() + -1 * 86400 * 1000).getTime() / 1000
1313
),
1414
to: Math.round(new Date().getTime() / 1000),
1515
query: "system.cpu.idle{*}",

examples/v1/service-level-objective-corrections/CreateSLOCorrection.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const params: v1.ServiceLevelObjectiveCorrectionsApiCreateSLOCorrectionRequest =
1818
category: "Scheduled Maintenance",
1919
description: "Example-Create_an_SLO_correction_returns_OK_response",
2020
end: Math.round(
21-
new Date(new Date().getTime() / 1000 + 1 * 3600).getTime() / 1000
21+
new Date(new Date().getTime() + 1 * 3600 * 1000).getTime() / 1000
2222
),
2323
sloId: SLO_DATA_0_ID,
2424
start: Math.round(new Date().getTime() / 1000),

examples/v1/service-level-objective-corrections/UpdateSLOCorrection.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const params: v1.ServiceLevelObjectiveCorrectionsApiUpdateSLOCorrectionRequest =
1818
category: "Deployment",
1919
description: "Example-Update_an_SLO_correction_returns_OK_response",
2020
end: Math.round(
21-
new Date(new Date().getTime() / 1000 + 1 * 3600).getTime() / 1000
21+
new Date(new Date().getTime() + 1 * 3600 * 1000).getTime() / 1000
2222
),
2323
start: Math.round(new Date().getTime() / 1000),
2424
timezone: "UTC",

examples/v1/service-level-objectives/GetSLOHistory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const SLO_DATA_0_ID = process.env.SLO_DATA_0_ID as string;
1414
const params: v1.ServiceLevelObjectivesApiGetSLOHistoryRequest = {
1515
sloId: SLO_DATA_0_ID,
1616
fromTs: Math.round(
17-
new Date(new Date().getTime() / 1000 + -1 * 86400).getTime() / 1000
17+
new Date(new Date().getTime() + -1 * 86400 * 1000).getTime() / 1000
1818
),
1919
toTs: Math.round(new Date().getTime() / 1000),
2020
};

0 commit comments

Comments
 (0)