{"id":18417527,"url":"https://github.com/plirof2/rrecurjs_rrule_to_json","last_synced_at":"2026-04-30T15:31:04.205Z","repository":{"id":67472682,"uuid":"104732372","full_name":"plirof2/rrecurjs_rrule_to_json","owner":"plirof2","description":"Convert RRULE to JSON (clone from https://git.daplie.com/coolaj86/rrecurjs/tree/master ) ","archived":false,"fork":false,"pushed_at":"2017-10-12T11:14:19.000Z","size":47,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-13T06:47:44.660Z","etag":null,"topics":["javascript","json","rrule","rrule2json"],"latest_commit_sha":null,"homepage":"http://plirof2.github.io/rrecurjs_rrule_to_json","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/plirof2.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-09-25T09:50:10.000Z","updated_at":"2017-10-12T11:14:42.000Z","dependencies_parsed_at":null,"dependency_job_id":"52f92b6a-5e4a-46d7-a686-2169e18b4942","html_url":"https://github.com/plirof2/rrecurjs_rrule_to_json","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/plirof2/rrecurjs_rrule_to_json","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plirof2%2Frrecurjs_rrule_to_json","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plirof2%2Frrecurjs_rrule_to_json/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plirof2%2Frrecurjs_rrule_to_json/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plirof2%2Frrecurjs_rrule_to_json/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/plirof2","download_url":"https://codeload.github.com/plirof2/rrecurjs_rrule_to_json/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plirof2%2Frrecurjs_rrule_to_json/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32469344,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-30T13:12:12.517Z","status":"ssl_error","status_checked_at":"2026-04-30T13:12:06.837Z","response_time":57,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["javascript","json","rrule","rrule2json"],"created_at":"2024-11-06T04:09:52.772Z","updated_at":"2026-04-30T15:31:04.172Z","avatar_url":"https://github.com/plirof2.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\nnote : rrule.js was taken from here : https://github.com/plirof2/rrule.git\n\n\nrrecur\n=======\n\nConvert between RFC2445 RRULE and its JSON equivalent.  Useful with `rrule.js`.\n\nIf you want UIs like these:\n\nGoogle Calendar: http://imgur.com/a/gT7Af\n\nThunderbird Calendar: http://imgur.com/a/LhnWU\n\nKendo Calendar: http://imgur.com/a/zVLyg\n\nYou need a library like this to actually interpret `RRULE`s and schedule the events.\n\nUsage\n====\n\nparse \u0026 stringify\n---\n\nThis snippet will work both in the Browser and with Node.js\n(hence the scary bit at the bottom).\n\nFrom JSON to RRULE\n\n```javascript\n(function (exports) {\n  'use strict';\n\n  var Rrecur = exports.Rrecur || require('rrecur').Rrecur\n    , rfcString\n    ;\n\n  rfcString = Rrecur.stringify({\n    \"freq\": \"monthly\"\n  , \"interval\": \"2\"\n  , \"count\": \"10\"\n  , \"byday\": [\"1su\",\"-1su\"]\n  });\n\n}('undefined' !== typeof exports \u0026\u0026 exports || new Function('return this')()));\n```\n\nFrom RRULE to JSON\n\n```javascript\n(function (exports) {\n  'use strict';\n\n  var Rrecur = exports.Rrecur || require('rrecur').Rrecur\n    , rfcString\n    ;\n\n  rfcString = Rrecur.stringify({\n    \"freq\": \"monthly\"\n  , \"interval\": \"2\"\n  , \"count\": \"10\"\n  , \"byday\": [\"1su\",\"-1su\"]\n  });\n\n}('undefined' !== typeof exports \u0026\u0026 exports || new Function('return this')()));\n```\n\nnext occurrence of an event\n---\n\n**Scenario**:\nI want an alarm to go off every day at 10:30am, given my location.\n\nSince we can't specify timezones with a JavaScript date object, we pretend internally that *local time* **is** *zoneless time*. UTC is handled exactly as UTC.\n\nSo let's say it's 8:00am on our server in Utah on the first day of summer\nand we want to set an alarm for 10:30am in New York (30 minutes from now)\nevery mon, wed, fri:\n\n```javascript\nvar rrecur\n  ;\n\nrrecur = Rrecur.create({\n  dtstart: Rrecur.toLocaleISOString(new Date(2014,06,21, 10,30,0), \"GMT-0400 (EDT)\")\n, locale: \"GMT-0400 (EDT)\"\n, byhour: [10]\n, byminute: [30]\n, byday: ['mo','we','fr'] // Or [Rrecur.weekdays[1], Rrecur.weekdays[3], Rrecur.weekdays[5]]\n, until: Rrecur.toAdjustedISOString(new Date(2014,06,22, 10,30,0), \"GMT-0400 (EDT)\")\n, freq: 'daily'\n, count: 1\n// `bysecond` will default to 00, since that's what's specified in `dtstart`\n}, new Date());\n\nrrecur.next(); // 2014-05-21T10:30:00.000-0400\n```\n\nIf you didn't specify `locale` then you would get back a time in UTC\nor in `GMT-0600 (MDT)` that you would need to manually adjust.\n\nInstallation\n===\n\n### browser\n\n**NOTE**: you only need `rrecur.js` for the basic `JSON \u003c-\u003e RRULE` conversion.\nIf you want to actually find the occurances you'll need\n`underscore.js`, `rrule.js`, and `moment.js`, and `rrecur-iterator.js`.\nHowever, in some future version I may be able to eliminate `underscore.js` and `rrule.js`.\n\nvia bower\n\n```bash\nbower install rrecur\n```\n\nvia download\n\n```bash\nwget https://raw2.github.com/coolaj86/rrecurjs/master/rrecur.js\nwget https://raw2.github.com/coolaj86/rrecurjs/master/rrecur-iterator.js\n```\n\nand insert the script tag, of course\n\n```html\n\u003cscript src=\"underscore.js\"\u003e\u003c/script\u003e\n\u003cscript src=\"rrule.js\"\u003e\u003c/script\u003e\n\u003cscript src=\"moment.js\"\u003e\u003c/script\u003e\n\u003cscript src=\"rrecur.js\"\u003e\u003c/script\u003e\n\u003cscript src=\"rrecur-iterator.js\"\u003e\u003c/script\u003e\n```\n\n```jade\nscript(src=\"underscore.js\")\nscript(src=\"rrule.js\")\nscript(src=\"moment.js\")\nscript(src=\"rrecur.js\")\nscript(src=\"rrecur-iterator.js\")\n```\n\nI know, it's a lot of dependencies... but that's just how it is.\nIn a future version it may be reasonable to drop `underscore` and `rrule`,\nbut `moment` is a must. JavaScript's Date object is just too messed up.\n\n\n### node.js\n\n```bash\nnpm install rrecur\n```\n\nAPI\n===\n\nConvert between RFC2445 RRULE and its JSON equivalent.\n\n* `Rrecur.parse(rruleStr)` - parses a string rrule (allows non-standard `dtstart` in string)\n* `Rrecur.stringify(rruleObj)` - stringifies an rrule object (allows non-standard `dtstart`)\n\nFind the next (or previous) occurence of an event in an rrule chain.\n\n* `Rrecur.create(rrule, localeDateString)` - creates a wrapped instance from `rrule.js` from an rrule object or string\n  * `localeDateString` - a string such as `Wed Jul 16 2014 10:30:00 GMT-0400 (EDT)`\n  * `Rrecur#previous()` - cycles backwards through time to find a previous instance up to `dtstart`\n  * `Rrecur#next()` - cycles forwards through time to find the next instance up to `until` or `count`\n\nUtility functions\n\n* `Rrecur.toLocaleISOString(date, [locale])` - ouput an ISO string with timezone information\n  * `2014-06-21T10:00:00.000-0600` instead of `Sat Jun 21 2014 10:15:08 GMT-0600 (MDT)` or `2014-06-21T16:00:00.000Z`\n  * If `locale` is specified in a format such as `-04:00` or `GMT-0400 (EDT)`, the local (not UTC) time is still used, but the offset is replaced with the supplied locale.\n* `Rrecur.toAdjustedISOString(date, locale)`\n  * `date` - A local date object (with the wrong timezone)\n  * `locale` A JavaScript Locale string (or Date string) with the desired timezone\n  * returns a UTC string adjusted to accurately represent the desired timezone\n\n### RRULEs\n\nYou put in an object like this:\n\n```json\n{ \"freq\": \"weekly\"\n, \"until\": \"2015-01-01T10:30:00.000Z\"\n, \"byday\": [\"tu\", \"th\"]\n, \"byhour\": [4]\n, \"byminute\": [30]\n}\n```\n\n* `freq` - `yearly|monthly|weekly|daily|hourly|minutely|secondly`\n* `interval` - bi-weekly, tri-weekly, etc\n* `bymonth`\n* `byweekno`\n* `byyearday`\n* `bymonthday`\n* `byday` - 0-7, su,mo,tu,we,th,fr,sa,su\n* `byhour`\n* `byminute`\n* `bysecond`\n* `until` - seems that this must be given in UTC as per spec, which is weird\n* `count` - how many occurrences\n* `wkst` - which day the week starts on 0-7, sa,su,mo\n* `bysetpos` - not sure how this works - http://www.kanzaki.com/docs/ical/recur.html\n* `dtstart` - specifies the first event (or a date close to it), non-standard as part of rrule, but is part of ical\n  * If you don't specify `dtstart`, the current time will be used.\n  * You cannot get `previous()` before `dtstart`\n* `locale` - specifies the locale in the format `GMT-0500 (EST)` - non-standard, in general\n* `tzid` - specifies the locale, non-standard as part of rrule, but is part of ical\n\nSee https://github.com/jkbr/rrule#api for implementation details.\n\n### Examples\n\nJSON version of iCal RRULE\n\n```json\n{ \"freq\": \"daily\"\n, \"until\": \"2015-01-01T10:30:00.000Z\"\n, \"byday\": [\"tu\", \"th\"]\n, \"byhour\": [4]\n, \"byminute\": [30]\n}\n```\n\nNon-standard iCal directive\n\n(once `TZID` is implemented, this will be standard)\n\n```\nDTSTART;LOCALE=GMT-0500 (EST):20140616T103000\nRRULE:FREQ=DAILY;BYHOUR=10;BYMINUTE=30;BYSECOND=0;UNTIL=20150616T153000Z\n```\n\nNon-standard iCal directive (`rrule.js` flavored)\n\n```\nDTSTART=20140616T103000Z;FREQ=DAILY;BYHOUR=10;BYMINUTE=30;BYSECOND=0;UNTIL=20150616T153000Z\n```\n\nTimezones\n===\n\nTimezones are a PAIN! Right!?\n\nHere are the problems:\n\n  * JavaScript's native Date object has only two options - *Locale* and *UTC*\n  * The server may have a different locale than the client\n  * `rrule.js` only operates on *Locale* - the local time of the server\n  * `RRULE`s are *zoneless* - 10:30am is meant to be in the user's time\n  * `DTSTART;TZID=America/New_York` isn't *yet* supported by `rrule.js`\n\nHere are solutions:\n\n  * `DTSTART` you can include `LOCALE` (recommended) or use UTC (confusing)\n  * `UNTIL` you must use UTC (confusing, but that's the way it is)\n    * Try `Rrecur.toAdjustedISOString(new Date(2014,06,16,10,30,00), 'GMT-0600 (MDT)')`\n  * `RRULE`s are *zoneless*, but we do our best to put them in the right zone.\n  * Everything is calculated in local time under the hood.\n\nRemember:\n\n* Always specify RRULEs in local time\n  * An RRULE for Monday at 10am will fire well after the sun is risen whether in California or China\n  * An RRULE for Monday at 10am will have a different UTC conversion in California than in China\n  * `dtstart` should always be in local time with a locale or in UTC\n  * `until` must be specified in UTC\n  * all calculations will be done in the local time of the server\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplirof2%2Frrecurjs_rrule_to_json","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fplirof2%2Frrecurjs_rrule_to_json","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplirof2%2Frrecurjs_rrule_to_json/lists"}