Skip to content

Commit

Permalink
Merge pull request #61 from commenthol/fix-set-unset-rule-throws
Browse files Browse the repository at this point in the history
Fix: set unset rule throws
  • Loading branch information
commenthol authored Nov 26, 2024
2 parents 358db79 + e99dcb9 commit 42f9a07
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x, 18.x, 20.x]
node-version: [18.x, 20.x, 22.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps:
- uses: actions/checkout@v3
Expand Down
28 changes: 14 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "date-holidays-parser",
"version": "3.4.4",
"version": "3.4.5-0",
"description": "parser for worldwide holidays",
"keywords": [
"holidays",
Expand Down Expand Up @@ -51,7 +51,7 @@
"prepublishOnly": "npm run all",
"test": "npm-run-all test:*",
"test:ci": "mocha",
"test:ts": "dtslint types",
"__disabled__test:ts": "dtslint types",
"test:tz": "TZ=UTC-10 mocha && TZ=UTC+10 mocha",
"zuul": "zuul test/Holidays.test.js"
},
Expand All @@ -64,26 +64,26 @@
"caldate": "^2.0.5",
"date-bengali-revised": "^2.0.2",
"date-chinese": "^2.1.4",
"date-easter": "^1.0.2",
"date-easter": "^1.0.3",
"deepmerge": "^4.3.1",
"jalaali-js": "^1.2.6",
"moment-timezone": "^0.5.43"
"jalaali-js": "^1.2.7",
"moment-timezone": "^0.5.46"
},
"devDependencies": {
"c8": "^7.13.0",
"c8": "^10.1.2",
"dtslint": "^4.2.1",
"eslint": "^8.40.0",
"eslint-config-standard": "^17.0.0",
"eslint-plugin-import": "^2.27.5",
"eslint": "^8.57.1",
"eslint-config-standard": "^17.1.0",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-n": "^15.7.0",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-promise": "^6.6.0",
"hashtree": "^0.7.0",
"mocha": "^10.2.0",
"mocha": "^11.0.0",
"npm-run-all": "^4.1.5",
"rimraf": "^5.0.0",
"rollup": "^2.79.1",
"rimraf": "^6.0.1",
"rollup": "^2.79.2",
"serialize-to-module": "^1.1.0",
"typescript": "^5.0.4"
"typescript": "^5.7.2"
},
"engines": {
"node": ">=12.0.0"
Expand Down
3 changes: 3 additions & 0 deletions src/Holidays.js
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,9 @@ export class Holidays {
*/
_dateByRule (year, rule) {
const _rule = this.holidays[rule]
if (!_rule?.fn?.inYear) {
return []
}
const dates = _rule.fn.inYear(year)
.get(this.__timezone)
.map((date) => {
Expand Down
1 change: 0 additions & 1 deletion src/PostRule.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import { get as _get, toNumber } from './utils.js'
import Rule from './Rule.js'
import CalEvent from './CalEvent.js'
Expand Down
20 changes: 20 additions & 0 deletions test/issue-set-unset-rule.mocha.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import assert from 'assert'
import Holidays from '../src/index.js'
import fixtures from './fixtures/index.cjs'

const fixture = fixtures.holidays

describe('#issue-set-unset-rule', function () {
it('should not throw if rule is unset', function () {
const hd = new Holidays(fixture, 'AR')
hd.unsetRule('12-31 12:00')
hd.setHoliday('12-31')
assert.deepEqual(hd.isHoliday('2024-12-31T12:00:00Z'), [{
date: '2024-12-31 00:00:00',
end: new Date('2025-01-01T03:00:00.000Z'),
name: '12-31',
start: new Date('2024-12-31T03:00:00.000Z'),
type: 'public'
}])
})
})

0 comments on commit 42f9a07

Please sign in to comment.