@quartz/is-go-go-day
Advanced tools
Comparing version 1.0.0 to 1.1.0
{ | ||
"name": "@quartz/is-go-go-day", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "ts_build/index.js", |
# is-go-go-day | ||
Determine if a day is a GO! GO! Day. | ||
Determine if a day is a [GO! GO! Day](https://gogocurryamerica.com/). | ||
```js | ||
const { isGoGoDay } = require( '@quartz/is-go-go-day' ); | ||
console.log( isGoGoDay() ); | ||
console.log( isGoGoDay( new Date('2020-01-14') ) ); | ||
console.log( isGoGoDay( new Date('2020-01-15T00:00:00-05:00') ) ); | ||
``` | ||
Or get a list of all GO! GO! Days for a given year. | ||
```js | ||
const { getGoGoDays } = require( '@quartz/is-go-go-day' ); | ||
console.log ( getGoGoDays( 2020 ) ); | ||
``` | ||
# Development | ||
To build: `npm run build` | ||
@@ -6,0 +26,0 @@ |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
// The static list of GO! GO! days in a year. | ||
const GO_GO_DAYS = [ | ||
'01-05', | ||
'01-15', | ||
'01-25', | ||
'02-05', | ||
'02-15', | ||
'02-25', | ||
'03-05', | ||
'03-15', | ||
'03-25', | ||
'04-05', | ||
'04-15', | ||
'04-25', | ||
'05-05', | ||
'05-15', | ||
'05-25', | ||
'06-05', | ||
'06-15', | ||
'06-25', | ||
'07-05', | ||
'07-15', | ||
'07-25', | ||
'08-05', | ||
'08-15', | ||
'08-25', | ||
'09-05', | ||
'09-15', | ||
'09-25', | ||
'10-05', | ||
'10-15', | ||
'10-25', | ||
'11-05', | ||
'11-15', | ||
'11-25', | ||
'12-05', | ||
'12-15', | ||
'12-25', | ||
]; | ||
const isGoGoDay = (date = new Date()) => date.getDate().toString().endsWith('5'); | ||
exports.isGoGoDay = isGoGoDay; | ||
const getGoGoDays = (year) => { | ||
// Expect a reasonable year. This code will die. | ||
if (year < 2000 || year >= 2100) { | ||
throw new Error('Please provide a year in this century.'); | ||
} | ||
return GO_GO_DAYS.map(it => `${year}-${it}`); | ||
}; | ||
exports.getGoGoDays = getGoGoDays; |
@@ -12,1 +12,11 @@ "use strict"; | ||
}); | ||
describe('getGoGoDays', () => { | ||
it('should list all go go days for a given year', () => { | ||
chai_1.expect(_1.getGoGoDays(2020)).to.have.lengthOf(36); | ||
chai_1.expect(_1.getGoGoDays(2020)[0]).to.equal('2020-01-05'); | ||
chai_1.expect(_1.getGoGoDays(2020)[35]).to.equal('2020-12-25'); | ||
}); | ||
it('should throw an error', () => { | ||
chai_1.expect(() => _1.getGoGoDays(1999)).to.throw(Error); | ||
}); | ||
}); |
3376
72
30