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

Commit

Permalink
Exported prevDay().
Browse files Browse the repository at this point in the history
  • Loading branch information
lourot committed Jun 25, 2018
1 parent defe93b commit cad59d2
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,11 @@ when it breaks.

## Changelog

**2.1.0** (2018-06-25):
* Exported helper function `prevDay()`.

**2.0.0** (2018-06-25):
* Exported some helper functions.
* Exported helper functions `stringToDate()` and `dateToString()`.

**1.0.0** (2018-06-11):
* Support for passing a GitHub API key.
Expand Down
4 changes: 4 additions & 0 deletions docs/advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,8 @@ console.log(date); // 2018-05-11T00:00:00.000Z

const dateString = githubContribs.dateToString(date);
console.log(dateString); // 2018-05-11

const dayBefore = githubContribs.prevDay(date); // Date() object
const dayBeforeString = githubContribs.dateToString(dayBefore);
console.log(dayBeforeString); // 2018-05-10
```
13 changes: 7 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,16 @@
return date.toISOString().substring(0, 10);
};

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

module.exports = {
fetch: fetchContribs,
stringToDate,
dateToString
dateToString,
prevDay
};

const fetchRetry = url => {
Expand Down Expand Up @@ -205,9 +211,4 @@
return result;
};

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

})();
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ghuser/github-contribs",
"version": "2.0.0",
"version": "2.1.0",
"description": "List all GitHub repos a user has contributed to since the beginning of time.",
"license": "Unlicense",
"repository": {
Expand Down

0 comments on commit cad59d2

Please sign in to comment.