Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid rrule string generated for single-digit year dtstart dates (ex: "0002-01-01") #623

Open
7 tasks done
jamesfulford opened this issue Apr 3, 2024 · 1 comment
Open
7 tasks done

Comments

@jamesfulford
Copy link

Reporting an issue

Thank you for taking an interest in rrule! Please include the following in
your report:

  • Verify that you've looked through existing issues for duplicates before
    creating a new one
  • Code sample reproducing the issue. Be sure to include all input values you
    are using such as the exact RRule string and dates.
  • Expected output
  • Actual output
  • The version of rrule you are using
  • Your operating system
  • 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
@Velua
Copy link

Velua commented Jun 2, 2024

Are you saying you have users trying to select the year 80? not like 1980?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants