Skip to content

Commit

Permalink
Merge ee8d194 into 330c85d
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinAdu committed Sep 22, 2019
2 parents 330c85d + ee8d194 commit a684744
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 13 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,14 @@ npm test

## Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/KevinAdu/nengo.

In lieu of a formal style guide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using the following command:

```bash
npm run-script lint
```

## License

The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
21 changes: 17 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,31 @@ module.exports = {

const periodOrdered = periodData.sort((a, b) => b.startYear - a.startYear);

if (gregorianYear < periodOrdered[periodOrdered.length - 1].startYear) return null;
if (gregorianYear < periodOrdered[periodOrdered.length - 1].startYear)
return null;

const exactPeriod = periodOrdered.find((period, i) => {
if (i === periodOrdered.length - 1) return true;
if (gregorianYear > period.startYear) return true;
if (gregorianYear === period.startYear && gregorianMonth > period.startMonth) return true;
if (gregorianYear === period.startYear && gregorianMonth === period.startMonth && gregorianDay >= period.startDay) return true;
if (
gregorianYear === period.startYear &&
gregorianMonth > period.startMonth
) {
return true;
}
if (
gregorianYear === period.startYear &&
gregorianMonth === period.startMonth &&
gregorianDay >= period.startDay
) {
return true;
}

return false;
});

const updatedPeriod = Object.assign(
{currentJapaneseYear: gregorianYear - exactPeriod.startYear + 1},
{ currentJapaneseYear: gregorianYear - exactPeriod.startYear + 1 },
exactPeriod
);

Expand Down
52 changes: 44 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe("#japaneseYear", () => {
expect(tokyoOlympicYear.currentJapaneseYear).to.equal(2);
});

it("should convert any date below the first recorded emperor calendar date to null", () => {
it("should convert any date below the first recorded emperor calendar date to null", () => {
const gennaYear = japaneseYear(new Date(1615, 6, 1));
const firstAdYear = japaneseYear(new Date(1600, 1, 1));

Expand Down

0 comments on commit a684744

Please sign in to comment.