{"id":15692733,"url":"https://github.com/arshadkazmi42/datetime-round","last_synced_at":"2025-07-19T04:03:05.791Z","repository":{"id":45003495,"uuid":"205422955","full_name":"arshadkazmi42/datetime-round","owner":"arshadkazmi42","description":"Round off datetime to fixed time interval","archived":false,"fork":false,"pushed_at":"2022-07-14T06:10:07.000Z","size":63,"stargazers_count":7,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-08T03:16:48.761Z","etag":null,"topics":["ceil","date","datetime","datetime-round","floor","math","moment","round","time"],"latest_commit_sha":null,"homepage":null,"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/arshadkazmi42.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"arshadkazmi42"}},"created_at":"2019-08-30T16:54:17.000Z","updated_at":"2024-06-05T14:52:59.000Z","dependencies_parsed_at":"2022-09-22T15:52:00.198Z","dependency_job_id":null,"html_url":"https://github.com/arshadkazmi42/datetime-round","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/arshadkazmi42/datetime-round","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arshadkazmi42%2Fdatetime-round","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arshadkazmi42%2Fdatetime-round/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arshadkazmi42%2Fdatetime-round/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arshadkazmi42%2Fdatetime-round/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arshadkazmi42","download_url":"https://codeload.github.com/arshadkazmi42/datetime-round/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arshadkazmi42%2Fdatetime-round/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265887001,"owners_count":23844322,"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":["ceil","date","datetime","datetime-round","floor","math","moment","round","time"],"created_at":"2024-10-03T18:39:37.179Z","updated_at":"2025-07-19T04:03:05.765Z","avatar_url":"https://github.com/arshadkazmi42.png","language":"JavaScript","funding_links":["https://github.com/sponsors/arshadkazmi42"],"categories":[],"sub_categories":[],"readme":"# datetime-round\n\n[![Build](https://github.com/arshadkazmi42/datetime-round/actions/workflows/nodejs.yml/badge.svg)](https://github.com/arshadkazmi42/datetime-round/actions/workflows/nodejs.yml)\n[![NPM Version](https://img.shields.io/npm/v/datetime-round.svg)](https://www.npmjs.com/package/datetime-round)\n[![NPM Downloads](https://img.shields.io/npm/dt/datetime-round.svg)](https://www.npmjs.com/package/datetime-round)\n[![Github Repo Size](https://img.shields.io/github/repo-size/arshadkazmi42/datetime-round.svg)](https://github.com/arshadkazmi42/datetime-round)\n[![LICENSE](https://img.shields.io/npm/l/datetime-round.svg)](https://github.com/arshadkazmi42/datetime-round/blob/master/LICENSE)\n[![Contributors](https://img.shields.io/github/contributors/arshadkazmi42/datetime-round.svg)](https://github.com/arshadkazmi42/datetime-round/graphs/contributors)\n[![Commit](https://img.shields.io/github/last-commit/arshadkazmi42/datetime-round.svg)](https://github.com/arshadkazmi42/datetime-round/commits/master)\n\nRounds off datetime to nearest interval\n\n## Install\n\n```\nnpm i datetime-round\n```\n\n## Usage\n\n```javascript\n\nconst DatetimeRound = require('datetime-round');\n\n\nDatetimeRound(moment('2019-08-30 10:11:25'), 30, 'minutes', 'ceil')\n  .format('YYYY-MM-DD HH:mm:ss');\n// 2019-08-30 10:30:00\n\nDatetimeRound(moment('2019-08-30 10:11:25'), 30, 'minutes', 'floor')\n  .format('YYYY-MM-DD HH:mm:ss');\n// 2019-08-30 10:00:00\n\nDatetimeRound(moment('2019-08-30 10:11:25'), 10, 'minutes', 'ceil')\n  .format('YYYY-MM-DD HH:mm:ss');\n// 2019-08-30 10:20:00\n\nDatetimeRound(moment('2019-08-30 10:11:25'), 10, 'minutes', 'floor')\n  .format('YYYY-MM-DD HH:mm:ss');\n// 2019-08-30 10:10:00\n\nDatetimeRound(moment('2019-08-30 10:11:25'), 5, 'minutes', 'ceil')\n  .format('YYYY-MM-DD HH:mm:ss');\n// 2019-08-30 10:15:00\n\nDatetimeRound(moment('2019-08-30 10:11:25'), 5, 'minutes', 'floor')\n  .format('YYYY-MM-DD HH:mm:ss');\n// 2019-08-30 10:10:00\n\n```\n\n## Params\n\nDatetimeRound will accept following parameters as input\n\n- **date**: String datetime / moment object\n- **interval**: Time interval till which time needs to be rounded to (integer)\n- **intervalType**: Type of interval (`minutes`, `hours`, `seconds`) \n  \u003e Refer to moment.duration docs for all available formats.\n- **method**: Rounding method, `floor`, `ceil` .... (It supports all the round methods available in NodeJS `Math` package)\n\n## Contributing\n\nInterested in contributing to this project?\nYou can log any issues or suggestion related to this library [here](https://github.com/arshadkazmi42/datetime-round/issues/new)\n\nRead our contributing [guide](CONTRIBUTING.md) on getting started with contributing to the codebase\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farshadkazmi42%2Fdatetime-round","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farshadkazmi42%2Fdatetime-round","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farshadkazmi42%2Fdatetime-round/lists"}