{"id":24079908,"url":"https://github.com/hypersoftllc/qc-date-round","last_synced_at":"2025-04-30T14:21:00.355Z","repository":{"id":135273317,"uuid":"156045058","full_name":"hypersoftllc/qc-date-round","owner":"hypersoftllc","description":"Rounds a date to the nearest interval.","archived":false,"fork":false,"pushed_at":"2018-11-04T17:21:23.000Z","size":26,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-03T09:05:15.839Z","etag":null,"topics":["date","date-time","javascript","round","utility-function"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hypersoftllc.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":"2018-11-04T03:17:17.000Z","updated_at":"2024-06-05T14:52:56.000Z","dependencies_parsed_at":"2023-05-21T23:15:08.941Z","dependency_job_id":null,"html_url":"https://github.com/hypersoftllc/qc-date-round","commit_stats":{"total_commits":11,"total_committers":1,"mean_commits":11.0,"dds":0.0,"last_synced_commit":"8d4c21b35728112686d351f9969593de130994c1"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hypersoftllc%2Fqc-date-round","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hypersoftllc%2Fqc-date-round/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hypersoftllc%2Fqc-date-round/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hypersoftllc%2Fqc-date-round/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hypersoftllc","download_url":"https://codeload.github.com/hypersoftllc/qc-date-round/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":233266719,"owners_count":18650225,"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":["date","date-time","javascript","round","utility-function"],"created_at":"2025-01-09T22:26:33.945Z","updated_at":"2025-01-09T22:26:34.887Z","avatar_url":"https://github.com/hypersoftllc.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @qc/date-round\r\n\r\nRounds a date to the nearest interval from 1 milliseconds up to 24 hours.\r\n\r\n\r\n## Installation\r\n\r\n```sh\r\nnpm install @qc/date-round\r\n\r\n# or\r\nyarn add @qc/date-round\r\n```\r\n\r\n\r\n## Usage\r\n\r\n```js\r\nimport { round } from '@qc/date-round'\r\n\r\nlet dateIn = new Date(Date.UTC(2000, 0, 1, 2, 34, 56))\r\nlet interval = 60 * 60 * 1000\r\nlet dateOut = round(dateIn, interval)\r\ndateIn === dateOut; // false\r\n```\r\n\r\n\r\n## Examples\r\n\r\n**Nearest Hour**\r\n\r\n```js\r\nimport { round } from '@qc/date-round'\r\n\r\nlet date = new Date(Date.UTC(2000, 0, 1, 2, 34, 56))\r\nconsole.log(date) // 2000-01-01T02:34:56\r\nlet interval = 60 * 60 * 1000\r\ndate = round(date, interval)\r\nconsole.log(date) // 2000-01-01T03:00:00\r\n```\r\n\r\n**Nearest Half Hour**\r\n\r\n```js\r\nimport { round } from '@qc/date-round'\r\n\r\nlet date = new Date(Date.UTC(2000, 0, 1, 2, 34, 56))\r\nconsole.log(date) // 2000-01-01T02:34:56\r\nlet interval = 30 * 60 * 1000\r\ndate = round(date, interval)\r\nconsole.log(date) // 2000-01-01T02:30:00\r\n```\r\n\r\n**Nearest 15 Minutes**\r\n\r\n```js\r\nimport { round } from '@qc/date-round'\r\n\r\nlet date = new Date(Date.UTC(2000, 0, 1, 2, 34, 56))\r\nconsole.log(date) // 2000-01-01T02:34:56\r\nlet interval = 15 * 60 * 1000\r\ndate = round(date, interval)\r\nconsole.log(date) // 2000-01-01T02:30:00\r\n```\r\n\r\n**Nearest Ten Minutes**\r\n\r\n```js\r\nimport { round } from '@qc/date-round'\r\n\r\nlet date = new Date(Date.UTC(2000, 0, 1, 2, 34, 56))\r\nconsole.log(date) // 2000-01-01T02:34:56\r\nlet interval = 10 * 60 * 1000\r\ndate = round(date, interval)\r\nconsole.log(date) // 2000-01-01T02:30:00\r\n```\r\n\r\n**Nearest Five Minutes**\r\n\r\n```js\r\nimport { round } from '@qc/date-round'\r\n\r\nlet date = new Date(Date.UTC(2000, 0, 1, 2, 34, 56))\r\nconsole.log(date) // 2000-01-01T02:34:56\r\nlet interval = 5 * 60 * 1000\r\ndate = round(date, interval)\r\nconsole.log(date) // 2000-01-01T02:35:00\r\n```\r\n\r\n**Nearest Minute**\r\n\r\n```js\r\nimport { round } from '@qc/date-round'\r\n\r\nlet date = new Date(Date.UTC(2000, 0, 1, 2, 34, 56))\r\nconsole.log(date) // 2000-01-01T02:34:56\r\nlet interval = 60 * 1000\r\ndate = round(date, interval)\r\nconsole.log(date) // 2000-01-01T02:35:00\r\n```\r\n\r\n**Nearest Second**\r\n\r\n```js\r\nimport { round } from '@qc/date-round'\r\n\r\nlet date = new Date(Date.UTC(2000, 0, 1, 2, 34, 56))\r\ndate.setMilliseconds(789)\r\nconsole.log(date) // 2000-01-01T02:34:56.789\r\nlet interval = 1000\r\ndate = round(date, interval)\r\nconsole.log(date) // 2000-01-01T02:35:57\r\n```\r\n\r\n**Nearest 250 Milliseconds**\r\n\r\n```js\r\nimport { round } from '@qc/date-round'\r\n\r\nlet date = new Date(Date.UTC(2000, 0, 1, 2, 34, 56))\r\ndate.setMilliseconds(789)\r\nconsole.log(date) // 2000-01-01T02:34:56.789\r\nlet interval = 250\r\ndate = round(date, interval)\r\nconsole.log(date) // 2000-01-01T02:35:57.75\r\n```\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhypersoftllc%2Fqc-date-round","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhypersoftllc%2Fqc-date-round","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhypersoftllc%2Fqc-date-round/lists"}