Skip to content
This repository was archived by the owner on Nov 8, 2020. It is now read-only.

Commit cad59d2

Browse files
committed
Exported prevDay().
1 parent defe93b commit cad59d2

File tree

4 files changed

+16
-8
lines changed

4 files changed

+16
-8
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,11 @@ when it breaks.
8080

8181
## Changelog
8282

83+
**2.1.0** (2018-06-25):
84+
* Exported helper function `prevDay()`.
85+
8386
**2.0.0** (2018-06-25):
84-
* Exported some helper functions.
87+
* Exported helper functions `stringToDate()` and `dateToString()`.
8588

8689
**1.0.0** (2018-06-11):
8790
* Support for passing a GitHub API key.

docs/advanced.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,8 @@ console.log(date); // 2018-05-11T00:00:00.000Z
5252

5353
const dateString = githubContribs.dateToString(date);
5454
console.log(dateString); // 2018-05-11
55+
56+
const dayBefore = githubContribs.prevDay(date); // Date() object
57+
const dayBeforeString = githubContribs.dateToString(dayBefore);
58+
console.log(dayBeforeString); // 2018-05-10
5559
```

index.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,16 @@
3333
return date.toISOString().substring(0, 10);
3434
};
3535

36+
// See https://stackoverflow.com/a/25114400/1855917
37+
const prevDay = date => {
38+
return new Date(date.getTime() - (24 * 60 * 60 * 1000));
39+
};
40+
3641
module.exports = {
3742
fetch: fetchContribs,
3843
stringToDate,
39-
dateToString
44+
dateToString,
45+
prevDay
4046
};
4147

4248
const fetchRetry = url => {
@@ -205,9 +211,4 @@
205211
return result;
206212
};
207213

208-
// See https://stackoverflow.com/a/25114400/1855917
209-
const prevDay = date => {
210-
return new Date(date.getTime() - (24 * 60 * 60 * 1000));
211-
};
212-
213214
})();

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@ghuser/github-contribs",
3-
"version": "2.0.0",
3+
"version": "2.1.0",
44
"description": "List all GitHub repos a user has contributed to since the beginning of time.",
55
"license": "Unlicense",
66
"repository": {

0 commit comments

Comments
 (0)