{"id":16351518,"url":"https://github.com/onhate/datelative","last_synced_at":"2025-10-09T19:11:02.039Z","repository":{"id":225400417,"uuid":"765907323","full_name":"onhate/datelative","owner":"onhate","description":"Relative string date expression to Javascript Date (+5m, -10days)","archived":false,"fork":false,"pushed_at":"2024-03-04T13:14:57.000Z","size":18,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-07T08:58:45.824Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/onhate.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2024-03-01T21:22:12.000Z","updated_at":"2024-10-28T17:36:18.000Z","dependencies_parsed_at":"2024-03-01T22:08:34.102Z","dependency_job_id":"989b9842-b37b-42dc-b864-e48aa69c2e4a","html_url":"https://github.com/onhate/datelative","commit_stats":null,"previous_names":["onhate/datelative"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/onhate/datelative","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onhate%2Fdatelative","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onhate%2Fdatelative/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onhate%2Fdatelative/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onhate%2Fdatelative/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/onhate","download_url":"https://codeload.github.com/onhate/datelative/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onhate%2Fdatelative/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279001982,"owners_count":26083243,"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","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2024-10-11T01:09:33.869Z","updated_at":"2025-10-09T19:11:02.000Z","avatar_url":"https://github.com/onhate.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Datelative\n\nI wrote it '-5m' ago.\n\n![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/onhate/datelative/ci.yaml?branch=main)\n![npm](https://img.shields.io/npm/v/datelative)\n![GitHub](https://img.shields.io/github/license/onhate/datelative)\n\nDatelative is a JavaScript library that converts relative date strings to actual date objects. It's a handy tool for dealing with date and time manipulations in your JavaScript applications.\n\n## Installation\n\nYou can install Datelative using npm:\n\n```bash\nnpm install datelative\n```\n\nOr using yarn:\n\n```bash\nyarn add datelative\n```\n\n## Usage\n\nFirst, import the `relativeToDate` function from the library:\n\n```javascript\nimport { relativeToDate } from 'datelative';\n```\n\nThen, you can use it to convert relative date strings to date objects. Here are some examples:\n\n```javascript\nconst reference = new Date(); // Optional reference date, defaults to the current date and time\n\n// Add 2 days to the reference date\nconst date1 = relativeToDate('+2 days', reference);\n\n// Subtract 2 days from the reference date\nconst date2 = relativeToDate('-2 days', reference);\n\n// Add 2 weeks to the reference date\nconst date3 = relativeToDate('+2 weeks', reference);\n\n// Subtract 2 weeks from the reference date\nconst date4 = relativeToDate('-2 weeks', reference);\n\n// ... and so on for months, years, quarters, milliseconds, seconds, minutes, and hours\n```\n\n# Available Units\n\nThe + sign is optional and can be omitted.\n\nThe space between the number and the unit is also optional.\n\nFor example `+2 ms` is the same as `2ms`.\n\n- +2 ms\n- +2 milliseconds\n- +2 s\n- +2 sec\n- +2 second\n- +2 seconds\n- +2 Second\n- +2 Seconds\n- +2 m\n- +2 min\n- +2 minute\n- +2 minutes\n- +2 Min\n- +2 Minute\n- +2 Minutes\n- +2 h\n- +2 hr\n- +2 Hr\n- +2 hour\n- +2 hours\n- +2 Hour\n- +2 Hours\n- +2 d\n- +2 D\n- +2 day\n- +2 days\n- +2 Day\n- +2 Days\n- +2 w\n- +2 W\n- +2 wk\n- +2 Wk\n- +2 week\n- +2 weeks\n- +2 Week\n- +2 Weeks\n- +2 M\n- +2 mon\n- +2 month\n- +2 months\n- +2 Month\n- +2 Months\n- +2 y\n- +2 Y\n- +2 yr\n- +2 yrs\n- +2 year\n- +2 years\n- +2 Year\n- +2 Years\n- +2 q\n- +2 qr\n- +2 Q\n- +2 Qr\n- +2 qtr\n- +2 quarter\n- +2 quarters\n- +2 Quarter\n- +2 Quarters\n\nsee [index.js](./index.js#L1) for all available units.\n\n## Testing\n\nThis library includes a comprehensive set of tests to ensure its functionality. You can run these tests using npm:\n\n```bash\nnpm test\n```\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a pull request.\n\n## License\n\nThis project is licensed under the terms of the MIT license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fonhate%2Fdatelative","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fonhate%2Fdatelative","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fonhate%2Fdatelative/lists"}