{"id":13528296,"url":"https://github.com/bashleigh/shleemy","last_synced_at":"2025-04-13T12:25:03.233Z","repository":{"id":36988864,"uuid":"333541367","full_name":"bashleigh/shleemy","owner":"bashleigh","description":":clock10:   Human readable datetime values for JavaScript and TypeScript.","archived":false,"fork":false,"pushed_at":"2025-02-24T00:49:13.000Z","size":293,"stargazers_count":30,"open_issues_count":3,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-10T14:01:41.239Z","etag":null,"topics":["date","datetime","human-readable","intervals"],"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/bashleigh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2021-01-27T19:47:32.000Z","updated_at":"2024-08-16T13:21:02.000Z","dependencies_parsed_at":"2024-08-16T14:45:00.635Z","dependency_job_id":"b76435ee-71bc-4012-9281-9a4184cd7451","html_url":"https://github.com/bashleigh/shleemy","commit_stats":{"total_commits":102,"total_committers":2,"mean_commits":51.0,"dds":"0.17647058823529416","last_synced_commit":"83784be2aca74483c427f5f0a05137ae42c72621"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bashleigh%2Fshleemy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bashleigh%2Fshleemy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bashleigh%2Fshleemy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bashleigh%2Fshleemy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bashleigh","download_url":"https://codeload.github.com/bashleigh/shleemy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245773380,"owners_count":20669765,"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","datetime","human-readable","intervals"],"created_at":"2024-08-01T06:02:24.215Z","updated_at":"2025-03-29T08:31:34.064Z","avatar_url":"https://github.com/bashleigh.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"## shleemy\n\u003cp\u003e\n  \u003cimg src=\"https://github.com/bashleigh/shleemy/workflows/Tests/badge.svg\" alt=\"test badge\"/\u003e\n  \u003ca href=\"https://www.npmjs.com/package/shleemy\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/shleemy.svg\"/\u003e\u003c/a\u003e\n  \u003ca href='https://coveralls.io/github/bashleigh/shleemy?branch=master'\u003e\u003cimg src='https://coveralls.io/repos/github/bashleigh/shleemy/badge.svg?branch=master' alt='Coverage Status' /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp\u003eSimple human readable intervals for those that don't want to go to time prison.\u003c/p\u003e\n\u003cp\u003eHandy interval diff object for customisable, rounded, human readable phrases such as \"in 3 days\", \"12 years ago\", \"a minute ago\", \"just now\".\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca target=\"_blank\" href=\"https://rickandmorty.fandom.com/wiki/Shleemypants\"\u003e\n    \u003cimg align=\"right\" width=\"150\" src=\"https://static.wikia.nocookie.net/rickandmorty/images/4/4d/Shleemy.png/revision/latest/scale-to-width-down/310?cb=20190830174941\" alt=\"shleemypants\"/\u003e\n  \u003c/a\u003e\n\n   - Small\n   - Mighty \n   - No dependencies\n   - Easy to use\n   - You won't go to time prison for messing with time\n\u003c/p\u003e\n\n\u003e Inspiration take from [Carbon](https://github.com/briannesbitt/carbon)\n\n### Install\n\n```bash\n$ yarn add shleemy\n```\n\nOr \n\n```npm\n$ npm i shleemy\n```\n\n### Usage\n\n##### Basic\n\nGet human readable values with tense information\n\n**Present**\n```ts\nimport { shleemy } from \"shleemy\";\n\nconst interval = shleemy(new Date());\n\nconsole.log(interval.forHumans); // \"just now\"\nconsole.log(interval.tense); // \"present\"\n```\n**Past**\n```ts\nimport { shleemy } from \"shleemy\";\n\nconst date = new Date();\ndate.setMinutes(date.getMinutes() - 3);\n\nconsole.log(shleemy(date).forHumans); // \"3 minutes ago\"\nconsole.log(shleemy(date).tense); // \"past\"\n```\n**Future**\n```ts\nimport { shleemy } from \"shleemy\";\n\nconst date = new Date();\ndate.setMinutes(date.getMinutes() + 70);\n\nconsole.log(shleemy(date).forHumans); // \"in an hour\"\nconsole.log(shleemy(date).tense); // \"future\"\n```\n\n##### interval values\n\n```ts\nimport { shleemy } from \"shleemy\";\n\nconst date = new Date();\ndate.setHours(date.getHours() - 3);\n\nconsole.log(shleemy(date).roundedHours); // 3\n```\n\n```ts\nimport { shleemy } from \"shleemy\";\n\nconst date = new Date();\ndate.setDays(date.getDays() - 12);\n\nconsole.log(shleemy(date).roundedDays); // 12\nconsole.log(shleemy(date).roundedWeeks); // 1\n```\n\n##### Basic Formatting\n\n```ts\nconst date = new Date();\ndate.setDays(date.getDays() - 12);\n\nconst interval = shleemy(date);\n\nconsole.log(interval.time); // 12:34\nconsole.log(interval.date); // 12/03/2021\n```\n\u003e No locale as of now, so you backwards date people will have to do with day/month/year. Soz\n\n### Output manipulation\n\nThe Shleemy object can be used as a string! \n\n```ts\nimport { shleemy } from \"shleemy\";\n\nconst date = new Date();\ndate.setDays(date.getDays() - 12);\n\nconst interval = shleemy(date);\n\nconsole.log(`added ${interval}`); // added 12 days ago;\nconsole.log(`${interval.replace('days', 'yonders')}`); // 12 yonders ago;\n```\n\n**Available properties**\n\n```ts\nimport { shleemy } from \"shleemy\";\n\nconst date = new Date();\ndate.setDays(date.getDays() - 12);\nconst interval = shleemy(date);\n\nconsole.log('seconds', interval.seconds);\nconsole.log('rounded seconds', interval.roundedSeconds);\nconsole.log('minutes', interval.minutes);\nconsole.log('rounded minutes', interval.roundedMinutes);\nconsole.log('hours', interval.hours);\nconsole.log('rounded hours', interval.roundedHours);\nconsole.log('days', interval.days);\nconsole.log('rounded days', interval.roundedDays);\nconsole.log('weeks', interval.weeks);\nconsole.log('rounded weeks', interval.roundedWeeks);\nconsole.log('months', interval.months);\nconsole.log('rounded months', interval.roundedMonths);\nconsole.log('years', interval.years);\nconsole.log('rounded years', interval.roundedYears);\nconsole.log('tense', interval.tense);\n```\n\u003e All properties will be positive values. You cannot have -3 days in the 4th dimension. Use `tense` for past/present/future value\n\n### Options\n\n```ts\nimport { shleemy, ShleemyInterval } from \"shleemy\";\n\nconst date = new Date();\ndate.setDays(date.getDays() - 12);\n\nconst toDate = new Date();\ntoDate.setDays(toDate.getDays() - 20);\n\nconsole.log(\n  shleemy(date, {\n    toDate: toDate, // default: new Date() (now)\n    rounding: 'ceil', // default: floor\n    humanReadable: {\n      past: (value, interval) =\u003e `${value} ${ShleemyInterval.pluralInterval(value, interval)} yonders ago`, // default: ShleemyInterval.toHumanReadablePast\n      future: (value, interval) =\u003e `in ${value} ${ShleemyInterval.pluralInterval(value, interval)} and you get the idea`, // default: ShleemyInterval.toHumanReadableFuture\n      present: () =\u003e `seconds ago!`, // default: \"just now\"\n    }\n  }).days\n); // 8\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbashleigh%2Fshleemy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbashleigh%2Fshleemy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbashleigh%2Fshleemy/lists"}