Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f25dbd1

Browse filesBrowse files
committed
Stabilize time check
1 parent 61f3a32 commit f25dbd1
Copy full SHA for f25dbd1

File tree

Expand file treeCollapse file tree

1 file changed

+7
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+7
-0
lines changed

‎src/test/java/org/kohsuke/github/GitHubStaticTest.java

Copy file name to clipboardExpand all lines: src/test/java/org/kohsuke/github/GitHubStaticTest.java
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ public void timeRoundTrip() throws Exception {
2626
Date instantSeconds = Date.from(instantNow.truncatedTo(ChronoUnit.SECONDS));
2727
Date instantMillis = Date.from(instantNow.truncatedTo(ChronoUnit.MILLIS));
2828

29+
// if we happen to land exactly on zero milliseconds, add 1 milli
30+
if (instantSeconds.equals(instantMillis)) {
31+
instantMillis = Date.from(instantNow.plusMillis(1).truncatedTo(ChronoUnit.MILLIS));
32+
}
33+
2934
// TODO: other formats
3035
String instantFormatSlash = formatDate(instantMillis, "yyyy/MM/dd HH:mm:ss ZZZZ");
3136
String instantFormatDash = formatDate(instantMillis, "yyyy-MM-dd'T'HH:mm:ss'Z'");
@@ -40,6 +45,7 @@ public void timeRoundTrip() throws Exception {
4045
assertThat(instantSeconds,
4146
equalTo(GitHub.parseDate(GitHub.printDate(instantSeconds))));
4247

48+
// printDate will truncate to the nearest second, so it should not be equal
4349
assertThat(instantMillis,
4450
not(equalTo(GitHub.parseDate(GitHub.printDate(instantMillis)))));
4551

@@ -49,6 +55,7 @@ public void timeRoundTrip() throws Exception {
4955
assertThat(instantSeconds,
5056
equalTo(GitHub.parseDate(instantFormatDash)));
5157

58+
// This parser does not truncate to the nearest second, so it will be equal
5259
assertThat(instantMillis,
5360
equalTo(GitHub.parseDate(instantFormatMillis)));
5461

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.