{"id":21241667,"url":"https://github.com/smhg/date-frequency-js","last_synced_at":"2025-07-10T20:31:04.087Z","repository":{"id":10429002,"uuid":"12591617","full_name":"smhg/date-frequency-js","owner":"smhg","description":"JavaScript temporal frequency library","archived":false,"fork":false,"pushed_at":"2021-09-22T09:37:28.000Z","size":130,"stargazers_count":9,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-06-23T10:56:29.832Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/smhg.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}},"created_at":"2013-09-04T13:39:04.000Z","updated_at":"2023-03-04T04:19:28.000Z","dependencies_parsed_at":"2022-08-28T01:12:11.064Z","dependency_job_id":null,"html_url":"https://github.com/smhg/date-frequency-js","commit_stats":null,"previous_names":[],"tags_count":37,"template":false,"template_full_name":null,"purl":"pkg:github/smhg/date-frequency-js","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smhg%2Fdate-frequency-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smhg%2Fdate-frequency-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smhg%2Fdate-frequency-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smhg%2Fdate-frequency-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/smhg","download_url":"https://codeload.github.com/smhg/date-frequency-js/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smhg%2Fdate-frequency-js/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264652660,"owners_count":23644302,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-11-21T00:56:37.203Z","updated_at":"2025-07-10T20:31:03.727Z","avatar_url":"https://github.com/smhg.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"frequency [![ci](https://github.com/smhg/date-frequency-js/actions/workflows/ci.yml/badge.svg)](https://github.com/smhg/date-frequency-js/actions/workflows/ci.yml)\n=========\n\u003e Temporal frequency library\n\n## Installation\n```sh\nnpm install --save date-frequency\n```\n\n## Usage\n```javascript\ncreateFrequency()\n  .on('hour', 10)\n  .on('minute', 30)\n  .next(); // next occurence of 10:30\n\n// or, with a ISO-inspired string format\ncreateFrequency('FT10M30')\n  .next(); // next occurence of 10:30\n\ncreateFrequency()\n  .on('day', 2, 'week')\n  .next(); // next Tuesday\n\n// all occurences of 10:00:00 in the next 5 days\nconst d = new Date();\ncreateFrequency()\n  .on('hour', 10)\n  .on('m', 0)\n  .on('s', 0)\n  .between(d, (new Date(+d)).setDate(d.getDate() + 5));\n```\n\n## Methods\n### createFrequency()\nConstructor takes a string notation or rules object.\n```javascript\ncreateFrequency('F3D/WT10H30M0S'); // every Wednesday at 10:30:00\n\n// equals to:\ncreateFrequency({D: {W: 3}, h: {D: 10}, m: {h: 30}, s: {m: 0}});\n```\n\n### .on(unit, value[, scope])\nAdd frequency rules by specifying a unit, a value to fix it to and, optionally, a scope.\n```javascript\nfrequency.on('hour', 10).on('minute', 0).on('second', 0);\n// each day at 10:00:00\n\nfrequency.on('day', 6).on('m', 30);\n// each 30 minutes after the hour of the 6th day of each month\n\nfrequency.on('d', 7, 'week');\n// Sundays at midnight\n```\n\nThe value argument can also be a string which matches the name of a predefined function available in the `fn` property of the constructor.\n```javascript\ncreateFrequency.fn.even = require('number-kind').even;\ncreateFrequency()\n\t.on('week', 'even', 'epoch')\n\t.on('h', 0)\n\t.on('m', 0)\n\t.on('s', 0);\n// days of even weeks at midnight\n```\n\n### .next([date])\nReturns the next occurence of the frequency after _or on_ the specified date. Please note that you are responsible for incrementing the date if you want to call `.next()` multiple times to get consecutive occurences.\nIf no date is specified, `new Date()` is used.\n\n### .between(start, end)\nReturns all occurences of the frequency between (and including) the specified start and end date.\n\n### .toString()\nReturns a string notation of the frequency.\n\n## Development\n* Clone repo \u0026 `npm install`.\n* Lint: `npm run lint`.\n* Test: `npm test`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmhg%2Fdate-frequency-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsmhg%2Fdate-frequency-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmhg%2Fdate-frequency-js/lists"}