Skip to content

Commit

Permalink
Optimize dates utils (wojtekmaj#259)
Browse files Browse the repository at this point in the history
* Add makeGetRange helper

* Add isValidDate helper

* Fixup makeGetRange

* Fix test names

* More compressed formatting of switch

* Add makeGetEdgeOfNeighbor helper

* Add docs

* Add makeGetEdgeOfNeighborMonth helper

* Remove getDifferentMonth function

* Add comments

* Add makeGetEnd helper

* Refactor toYearLabel
  • Loading branch information
wojtekmaj authored and felixmosh committed Nov 8, 2020
1 parent 79610b6 commit e5b7ae6
Show file tree
Hide file tree
Showing 2 changed files with 151 additions and 250 deletions.
8 changes: 4 additions & 4 deletions src/shared/__tests__/dates.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ describe('getCenturyRange', () => {
});
});

describe('getBeginPreviousOfCentury', () => {
describe('getBeginOfPreviousCentury', () => {
it('returns proper beginning of the previous century', () => {
const date = new Date(2017, 0, 1);
const beginOfPreviousCenturyDate = new Date(1901, 0, 1);
Expand Down Expand Up @@ -301,7 +301,7 @@ describe('getDecadeRange', () => {
});
});

describe('getBeginPreviousOfDecade', () => {
describe('getBeginOfPreviousDecade', () => {
it('returns proper beginning of the previous decade', () => {
const date = new Date(2017, 0, 1);
const beginOfPreviousDecadeDate = new Date(2001, 0, 1);
Expand Down Expand Up @@ -369,7 +369,7 @@ describe('getYearRange', () => {
});
});

describe('getBeginPreviousOfYear', () => {
describe('getBeginOfPreviousYear', () => {
it('returns proper beginning of the previous year', () => {
const date = new Date(2017, 0, 1);
const beginOfPreviousYearDate = new Date(2016, 0, 1);
Expand Down Expand Up @@ -484,7 +484,7 @@ describe('getMonthRange', () => {
});
});

describe('getBeginPreviousOfMonth', () => {
describe('getBeginOfPreviousMonth', () => {
it('returns proper beginning of the previous month', () => {
const date = new Date(2017, 0, 1);
const beginOfPreviousMonthDate = new Date(2016, 11, 1);
Expand Down
Loading

0 comments on commit e5b7ae6

Please sign in to comment.