{"id":15819385,"url":"https://github.com/xunnamius/relative-random-time","last_synced_at":"2025-10-16T16:30:41.244Z","repository":{"id":57352679,"uuid":"301282018","full_name":"Xunnamius/relative-random-time","owner":"Xunnamius","description":"⛔️ [DEPRECATED] Quickly and easily get \"fuzzy\" millisecond counts in the near/far past/future. Useful when you need to generate times relative to other times","archived":false,"fork":false,"pushed_at":"2024-08-22T12:33:22.000Z","size":1265,"stargazers_count":1,"open_issues_count":7,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-08-22T13:59:55.482Z","etag":null,"topics":["clock","date","future","fuzzy","hour","millisecond","minute","moment","past","random","relative","second","time","timer","unit"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/Xunnamius.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":"2020-10-05T03:18:48.000Z","updated_at":"2024-08-22T12:31:59.000Z","dependencies_parsed_at":"2022-09-17T13:51:54.951Z","dependency_job_id":null,"html_url":"https://github.com/Xunnamius/relative-random-time","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Xunnamius%2Frelative-random-time","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Xunnamius%2Frelative-random-time/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Xunnamius%2Frelative-random-time/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Xunnamius%2Frelative-random-time/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Xunnamius","download_url":"https://codeload.github.com/Xunnamius/relative-random-time/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219869887,"owners_count":16555391,"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":["clock","date","future","fuzzy","hour","millisecond","minute","moment","past","random","relative","second","time","timer","unit"],"created_at":"2024-10-05T06:40:43.349Z","updated_at":"2025-10-16T16:30:40.900Z","avatar_url":"https://github.com/Xunnamius.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!-- badges-start --\u003e\n\n[![Black Lives Matter!][badge-blm]][link-blm]\n[![!!UNMAINTAINED!!][badge-unmaintained]][link-unmaintained]\n\n\u003c!-- badges-end --\u003e\n\n# ⛔️ DEPRECATED/UNMAINTAINED\n\n\u003e [!CAUTION]\n\u003e\n\u003e Time is hard. This package gets it wrong. Use something like\n\u003e [Temporal](https://github.com/tc39/proposal-temporal) or\n\u003e [various other powerful date/time libraries](https://momentjs.com/docs/#/-project-status/recommendations/).\n\nQuickly and easily get \\\"fuzzy\\\" millisecond counts in the near/far past/future.\nUseful when you need to work with times relative to other times. For example,\nwhen generating database entries during unit testing, maybe you want the entries\nto have logical \"created by\" dates that occur randomly in time but are well\nordered: one after the other.\n\nThis package includes TypeScript types and provides:\n\n- A UMD/CJS/AMD bundle (no tree-shaking)\n- ES2015 modules (tree-shaking)\n\n## Install\n\n```sh\nnpm install relative-random-time\n```\n\n## Usage\n\n```typescript\nimport * as Time from 'relative-random-time';\n\n// What time is it (in milliseconds) right now?\nconst now = Time.present();\n// \u003c== same as Date.now()\nconsole.log(new Date(now).toString());\n// \u003c== Tue Oct 06 2020 12:00:33 GMT-0700 (Pacific Daylight Time)\n\n// Suppose we want a time in the near future relative to right now\nconst nearFuture = Time.nearFuture();\nconsole.log(new Date(nearFuture).toString());\n// \u003c== Tue Oct 06 2020 12:01:24 GMT-0700 (Pacific Daylight Time)\n\n// We want another time in the near future relative to the time we just\n// generated (i.e. a time that comes *after* the previously generated time).\nconst lessNearFuture = Time.nearFuture({ after: nearFuture });\nconsole.log(new Date(lessNearFuture).toString());\n// \u003c== Tue Oct 06 2020 12:01:38 GMT-0700 (Pacific Daylight Time)\n\n// Now suppose we want a time in the near future relative to nearFuture\n// that is also no greater than a minute from now. That is:\n// nearFuture \u003c what we want \u003c now + 1 minute\nconst oneMinuteInMs = 1000 * 60;\nconst nearFutureOneMinute = Time.nearFuture({\n  after: nearFuture,\n  before: now + oneMinuteInMs\n});\nconsole.log(new Date(nearFutureOneMinute).toString());\n// \u003c== Tue Oct 06 2020 12:01:32 GMT-0700 (Pacific Daylight Time)\n\n// And if we wanted a time in the far future, we could ask for that instead.\nconst farFuture = Time.farFuture();\nconsole.log(new Date(farFuture).toString());\n// \u003c== Tue Feb 01 2050 20:32:23 GMT-0800 (Pacific Standard Time)\n\n// We can use before/after the same way, i.e. we want a time in the far future\n// that occurs *before* farFuture.\nconst nearerFarFuture = Time.farFuture({ before: farFuture });\nconsole.log(new Date(nearerFarFuture).toString());\n// \u003c== Wed Feb 09 2033 14:10:28 GMT-0800 (Pacific Standard Time)\n\n// Note, however, that nearFuture and farFuture will only return times that are\n// in the future relative to right now. They will never return times in the past\n// no matter what params are passed in. If we wanted a time in the past,\n// there are functions for that too.\nconst nearPast = Time.nearPast();\nconst farPast = Time.farPast();\nconst furtherPast = Time.farPast({ before: farPast });\n\nconsole.log(new Date(nearPast).toString());\n// \u003c== Tue Oct 06 2020 12:00:06 GMT-0700 (Pacific Daylight Time)\nconsole.log(new Date(farPast).toString());\n// \u003c== Sun Aug 28 2016 12:59:13 GMT-0700 (Pacific Daylight Time)\nconsole.log(new Date(furtherPast).toString());\n// \u003c== Thu Sep 17 1992 04:54:05 GMT-0700 (Pacific Daylight Time)\n\n// And this one will be a time before (earlier than) farPast but after (later\n// than) furtherPast!\nconst nearerFarPast = Time.farPast({ before: farPast, after: furtherPast });\nconsole.log(new Date(nearerFarPast).toString());\n// \u003c== Fri Jun 27 1997 20:59:42 GMT-0700 (Pacific Daylight Time)\n```\n\n## Documentation\n\nDocumentation can be found under [`docs/`](docs/README.md) and can be built with\n`npm run build-docs`.\n\n## Contributing\n\nIssues and pull requests are welcome! In lieu of a formal styleguide, take care\nto maintain the existing coding style.\n\nAdd unit tests for any new or changed functionality. Please lint and test your\ncode!\n\n## Release History\n\n- 1.0.x Initial release\n\n[badge-blm]: https://xunn.at/badge-blm 'Join the movement!'\n[link-blm]: https://xunn.at/donate-blm\n[badge-unmaintained]:\n  https://xunn.at/badge-unmaintained\n  'Unfortunately, this project is unmaintained (forks welcome!)'\n[link-unmaintained]: https://xunn.at/link-unmaintained\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxunnamius%2Frelative-random-time","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxunnamius%2Frelative-random-time","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxunnamius%2Frelative-random-time/lists"}