{"_id":"@cunneen/recurring-date","_rev":"1-39e4adfeee09ab36059d29d0bd471a46","name":"@cunneen/recurring-date","dist-tags":{"latest":"1.1.0"},"versions":{"1.0.0":{"name":"@cunneen/recurring-date","version":"1.0.0","keywords":["momentjs","recurring","dates"],"author":{"name":"Nathan Oehlman"},"license":"MIT","_id":"@cunneen/recurring-date@1.0.0","maintainers":[{"name":"cunneen","email":"mike@appworkshop.net"}],"contributors":[{"url":"https://github.com/cunneen","name":"Mike Cunneen"},{"url":"https://github.com/mattgrayson","name":"Matt Grayson"},{"url":"https://github.com/mooman","name":"Rachot Moragraan"}],"homepage":"https://github.com/cunneen/recurring-date#readme","bugs":{"url":"https://github.com/cunneen/recurring-date/issues"},"dist":{"shasum":"f35ee27bc0a1ff617f3b91962b81958a68f682c9","tarball":"https://registry.npmjs.org/@cunneen/recurring-date/-/recurring-date-1.0.0.tgz","fileCount":30,"integrity":"sha512-BjaXlSvaMGIrESQjnmp+kYnml9opk6pMn4oYfwFrjjOgVMOFjZqkIj2UfK0+eOPY7ydzzPwLZ9XqfNGeXqYoYQ==","signatures":[{"sig":"MEUCIBsLYbA84l7wmxcJqWJjCFWYb+hSRtpWi7ccOsAje2OBAiEAwY7hol3X0n2gpVa69XhdsPdWkW3dMaXJVuOhfwmmoBc=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":113947},"main":"lib/RecurringDate.js","types":"types/RecurringDate.d.ts","engines":{"node":"^18.18.0 || ^20.9.0 || >=21.1.0"},"gitHead":"4f0d912fd5b9b9edb66715cf8da280724750c7fc","scripts":{"test":"mocha --reporter spec","types":"tsc","browserify":"browserify --standalone RecurringDate --debug --outfile dist/recurring-date.js ./index.js"},"_npmUser":{"name":"cunneen","email":"mike@appworkshop.net"},"repository":{"url":"git+https://github.com/cunneen/recurring-date.git","type":"git"},"_npmVersion":"10.8.2","description":"Generate a list of dates that repeat based on a given schedule","directories":{},"_nodeVersion":"18.20.6","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"dayjs":"^1.11.13","mocha":"^11.1.0","eslint":"^9.20.1","moment":"2.30.1","globals":"^15.15.0","@eslint/js":"^9.20.0","browserify":"^17.0.1","typescript":"^5.7.3","@types/chai":"^5.0.1","@types/mocha":"^10.0.10","@types/moment":"^2.11.29"},"peerDependencies":{"dayjs":"^1.11.13","moment":"2.30.1"},"_npmOperationalInternal":{"tmp":"tmp/recurring-date_1.0.0_1740077631825_0.42123315558493135","host":"s3://npm-registry-packages-npm-production"}},"1.1.0":{"name":"@cunneen/recurring-date","version":"1.1.0","description":"Generate a list of dates that repeat based on a given schedule","main":"lib/RecurringDate.js","types":"types/RecurringDate.d.ts","publishConfig":{"access":"public"},"scripts":{"test":"mocha --reporter spec","types":"tsc","release-changelog":"git-cliff --unreleased --prepend CHANGELOG.md --tag ","release":"dotenvx run release-it -- -i -u","prepare":"husky"},"repository":{"type":"git","url":"git+https://github.com/cunneen/recurring-date.git"},"keywords":["momentjs","recurring","dates"],"author":{"name":"Nathan Oehlman"},"license":"MIT","peerDependencies":{"dayjs":"^1.11.13","moment":"^2.30.1"},"peerDependenciesMeta":{"dayjs":{"optional":true},"moment":{"optional":true}},"contributors":[{"name":"Mike Cunneen","url":"https://github.com/cunneen"},{"name":"Matt Grayson","url":"https://github.com/mattgrayson"},{"name":"Rachot Moragraan","url":"https://github.com/mooman"}],"devDependencies":{"@commitlint/cli":"^19.7.1","@commitlint/config-conventional":"^19.7.1","@eslint/js":"^9.20.0","@types/chai":"^5.0.1","@types/mocha":"^10.0.10","@types/moment":"^2.11.29","browserify":"^17.0.1","dayjs":"^1.11.13","eslint":"^9.20.1","git-cliff":"^2.8.0","globals":"^15.15.0","husky":"^9.1.7","mocha":"^11.1.0","moment":"2.30.1","release-it":"^18.1.2","sass":"^1.85.0","typescript":"^5.7.3"},"engines":{"node":"^18.18.0 || ^20.9.0 || >=21.1.0"},"_id":"@cunneen/recurring-date@1.1.0","gitHead":"d3487957dd319e2b210fccd7e4f30939a19a983b","bugs":{"url":"https://github.com/cunneen/recurring-date/issues"},"homepage":"https://github.com/cunneen/recurring-date#readme","_nodeVersion":"18.20.6","_npmVersion":"10.8.2","dist":{"integrity":"sha512-CmF47njUxk0S+mq0DlsTur/TiW8qnxsQJ+AN0ZsmGb2NAWXRKrayoKj2Mcr/fiXcyQVKmzNuq8ufeHr1mXlpxA==","shasum":"618b4e83e62d0bc93819261df64e9a946ea8d4de","tarball":"https://registry.npmjs.org/@cunneen/recurring-date/-/recurring-date-1.1.0.tgz","fileCount":11,"unpackedSize":38717,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDYPudoAgOwTHiJJglWbAFsB+W3PHNDo0voEcfd5nJxAQIhALKQBZJUJSQR9YaUsQvuyG73ChQpCmyUdORSJFATsnl7"}]},"_npmUser":{"name":"cunneen","email":"mike@appworkshop.net"},"directories":{},"maintainers":[{"name":"cunneen","email":"mike@appworkshop.net"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/recurring-date_1.1.0_1740412620503_0.5770613412309997"},"_hasShrinkwrap":false}},"time":{"created":"2025-02-20T18:53:51.737Z","modified":"2025-02-24T15:57:00.883Z","1.0.0":"2025-02-20T18:53:52.044Z","1.1.0":"2025-02-24T15:57:00.716Z"},"bugs":{"url":"https://github.com/cunneen/recurring-date/issues"},"author":{"name":"Nathan Oehlman"},"license":"MIT","homepage":"https://github.com/cunneen/recurring-date#readme","keywords":["momentjs","recurring","dates"],"repository":{"type":"git","url":"git+https://github.com/cunneen/recurring-date.git"},"description":"Generate a list of dates that repeat based on a given schedule","contributors":[{"name":"Mike Cunneen","url":"https://github.com/cunneen"},{"name":"Matt Grayson","url":"https://github.com/mattgrayson"},{"name":"Rachot Moragraan","url":"https://github.com/mooman"}],"maintainers":[{"name":"cunneen","email":"mike@appworkshop.net"}],"readme":"# recurring-date\n\nA zero-dependency* JavaScript library to generate recurring dates i.e. dates that repeat on a regular schedule  (e.g. \"Every 3 days\", or \"Every third Tuesday and Thursday\").\n\n(*momentjs or dayjs must be installed as a peer dependency)\n\nSee the [interactive demo][demo]\n\nFor example:\n\n```txt\nEvery 2 weeks on Monday, Wednesday, and Friday starting today for 5 occurrences\n```\n\n```txt\nEvery month on the last Sunday starting on 02/10/09 until 03/30/10\n```\n\nThis library will generate an array of dates for those patterns.\n\n---\n\n## Installation\n\n```console\nnpm install moment\nnpm install @cunneen/recurring-date\n```\n\n## Usage\n\n```js\nvar RecurringDate = require('@cunneen/recurring-date');\nvar moment = require('moment');\nRecurringDate.initializeWithDateLibrary(moment);\n// Every day starting on Sunday, February 21, 2010 until Sunday, March 7, 2010\nvar r = new RecurringDate({\n  start: \"02/21/2010\",\n  until: \"03/07/2010\",\n  every: \"1\",\n  unit: \"d\",\n  end_condition: \"until\",\n  date_format: \"MM/DD/YYYY\",\n  timezone: 480, // UTC+8 i.e. 8 hours * 60 = 480 minutes  \n});\nvar dates = r.generate();\n\n// dates is now an array of moment objects:\n// [\n//   Moment<2010-02-21T00:00:00+08:00>,\n//   Moment<2010-02-22T00:00:00+08:00>,\n//   Moment<2010-02-23T00:00:00+08:00>,\n//   Moment<2010-02-24T00:00:00+08:00>,\n//   Moment<2010-02-25T00:00:00+08:00>,\n//   Moment<2010-02-26T00:00:00+08:00>,\n//   Moment<2010-02-27T00:00:00+08:00>,\n//   Moment<2010-02-28T00:00:00+08:00>,\n//   Moment<2010-03-01T00:00:00+08:00>,\n//   Moment<2010-03-02T00:00:00+08:00>,\n//   Moment<2010-03-03T00:00:00+08:00>,\n//   Moment<2010-03-04T00:00:00+08:00>,\n//   Moment<2010-03-05T00:00:00+08:00>,\n//   Moment<2010-03-06T00:00:00+08:00>,\n//   Moment<2010-03-07T00:00:00+08:00>\n// ]\n```\n\nThis is a fork of mooman's [recurring_dates](https://github.com/mooman/recurring_dates).\n\n## Demo\n\nSee the [interactive demo][demo]\n\n### Changes in this fork\n\n- Removed all hard dependencies:\n  - dayjs or momentjs (or a momentjs-compatible library) is required as a peer dependency\n- Added types\n- Fixed some issues around timezones\n- Replaced browser tests with mocha\n- a date format is now required input\n\n#### Requirements\n\n- dayjs or momentjs is required as a peer dependency\n\n#### API\n\n    Class RecurringDate (pattern [, date_format])\n\nwhere pattern is a JSON object with the following options:\n\n- start: start date. date. required.\n- every: interval magnitude (every XXX weeks...). integer. required.\n- unit: valid values are 'd', 'w', 'm', 'y' for days, weeks, months, and years\n  respectively. probably required.\n- end_condition: how should the recurrence be terminated.\n  valid values are 'until' and 'for'. 'until' should be a date.\n  'for' should be an integer (for N occurrences). required.\n- until: if end_condition is 'until', pass the date here.\n- rfor: if end_condition is 'for', pass an integer here.\n- nth: valid values are 'first', 'second', 'third', 'fourth', and 'last'.\n  see 'occurrence_of' option. to be used with 'm' unit option.\n- date_format: date format string, as specified by [momentjs](http://momentjs.com/docs/#/parsing/string-format/). required.\n- moment_locale: locale string, as specified by [momentjs](http://momentjs.com/docs/#/parsing/string-format/). Default is 'en'.\n- timezone: A UTC offset in minutes, as per [momentjs utcOffset()](https://momentjs.com/docs/#/manipulating/utc-offset/)\n- occurrence_of: valid values are 0-6, corresponding to the days of the week.\n  in conjuction with 'nth' option, specifies nth day of the month\n  (last Sunday of the month). to be used with 'm' unit option.\n- days: to be used with 'w' unit option. an array of integers representing day\n  of the week (0-6). eg. Every 2 weeks on Tuesday (2) and Thursday (4),\n  pass [2,4] as the value.\n\nex.\n    { start: new Date(), every: 2, unit: 'w', end_condition: 'for', rfor: 5, days: [1,3,5] }\n    generates:\n    Every 2 weeks on Monday, Wednesday, and Friday for 5 occurrences starting today\n\n---\n\n    static RecurringDate.initializeWithDateLibrary (dateLibrary)\n\nInitializes the RecurringDate class with a date library (e.g. moment or dayjs).\n\nFor example:\n    RecurringDate.initializeWithDateLibrary(dayjs);\n\n---\n\n    String describe ()\n\nTries to describe the supplied pattern in English.\n\n---\n\n    Boolean contains (date)\n\nDetermines whether \"date\" is in the recurrence pattern. This calls generate(),\nif it hasn't already been generated, otherwise, it will use the dates generated\nfrom the last time generate() was called. Returns true if \"date\" is in the pattern.\n\"date\" can be either a string or a Date object, but please make sure the time\nportion is all balls (00:00:00).\n\nNote that this only check if \"date\" is contained within the pattern's starting and\nending points. Next version will support indefinite ending date and throwaway dates\ngeneration, instead of storing them all in an array.\n\n-----\n\n    Date[] generate ([limit])\n\nGenerate the dates based on supplied pattern. Returns array of Date objects.\nOptional argument limit puts an upper limit on how many dates to generate\n(for preview or to prevent some memory leak).\n\n### TODO\n\n- Indefinite ending date (seems to be working if occurences == 0)\n- Throwaway date generation (not store in array, but just output it)\n\n### CHANGELOG\n\nSee [CHANGELOG.md][changelog]\n\n### COMMENTS\n\nPlease feel free fork and improve, submit bug reports, suggestions, comments.\n\n### LICENSE\n\nReleased under MIT License.\n\n<!-- links -->\n[demo]:https://cunneen.github.io/recurring-date/\n[changelog]:./CHANGELOG.md\n","readmeFilename":"README.md"}