rrule
rrule copied to clipboard
Invalid rrule string generated for single-digit year dtstart dates (ex: "0002-01-01")
Reporting an issue
Thank you for taking an interest in rrule
! Please include the following in
your report:
- [x] Verify that you've looked through existing issues for duplicates before creating a new one
- [x] Code sample reproducing the issue. Be sure to include all input values you are using such as the exact RRule string and dates.
- [x] Expected output
- [x] Actual output
- [x] The version of
rrule
you are using - [x] Your operating system
- [x] Your local timezone (run
$ date
from the command line of the machine showing the bug)
Code reproduction:
const rrule = require('rrule');
console.log(rrule.rrulestr(new rrule.RRule({ dtstart: new Date("0010-01-01T00:00:00Z") }).toString()));
Expected: any RRule object Actual: error is thrown:
Uncaught Error: Invalid UNTIL value: 00,20101T000000Z
at untilStringToDate (/Users/jamesfulford/solomon-app/node_modules/rrule/dist/es5/rrule.js:370:15)
at parseDtstart (/Users/jamesfulford/solomon-app/node_modules/rrule/dist/es5/rrule.js:2165:23)
at parseInput (/Users/jamesfulford/solomon-app/node_modules/rrule/dist/es5/rrule.js:3429:25)
at buildRule (/Users/jamesfulford/solomon-app/node_modules/rrule/dist/es5/rrule.js:3477:14)
at Module.rrulestr (/Users/jamesfulford/solomon-app/node_modules/rrule/dist/es5/rrule.js:3512:12)
It seems that for single-digit year dtstart dates, rrule throws exceptions.
This matters because my app displays a preview of dates while the user is editing the dtstart, and "0002-01-01" is common when the user selects the year and starts typing in the year field (using the build-in <input type="date" />
selector). (Funnily enough, this was a user-discovered bug!) I'm able to fix it in my app by handling when the rrule string generated is invalid, but the library should be producing a valid rrule string in this scenario.
Operating system: MacOS Ventura 13.6.3 Node version: v18.19.0 rrule package version: 2.8.1
Timezone:
$ date
Wed Apr 3 11:38:30 MDT 2024
Are you saying you have users trying to select the year 80? not like 1980?