Skip to content

Commit a4c1c8d

Browse files
KostyaShakohsuke
authored andcommitted
Provide reset date info for rate limit
1 parent 0bf81f4 commit a4c1c8d

1 file changed

Lines changed: 20 additions & 2 deletions

File tree

src/main/java/org/kohsuke/github/GHRateLimit.java

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package org.kohsuke.github;
22

3+
import java.util.Date;
4+
35
/**
46
* Rate limit.
57
* @author Kohsuke Kawaguchi
@@ -10,12 +12,28 @@ public class GHRateLimit {
1012
*/
1113
public int remaining;
1214
/**
13-
* Alotted API call per hour.
15+
* Allotted API call per hour.
1416
*/
1517
public int limit;
1618

19+
/**
20+
* The time at which the current rate limit window resets in UTC epoch seconds.
21+
*/
22+
public Date reset;
23+
24+
/**
25+
* Non-epoch date
26+
*/
27+
public Date getResetDate() {
28+
return new Date(reset.getTime() * 1000);
29+
}
30+
1731
@Override
1832
public String toString() {
19-
return remaining+"/"+limit;
33+
return "GHRateLimit{" +
34+
"remaining=" + remaining +
35+
", limit=" + limit +
36+
", resetDate=" + getResetDate() +
37+
'}';
2038
}
2139
}

0 commit comments

Comments
 (0)