{"id":15397008,"url":"https://github.com/ryanhefner/relative-time-webcomponent","last_synced_at":"2025-04-04T22:41:53.159Z","repository":{"id":57352690,"uuid":"56998439","full_name":"ryanhefner/relative-time-webcomponent","owner":"ryanhefner","description":"A simple web component used to render relative time.","archived":false,"fork":false,"pushed_at":"2016-04-26T12:31:51.000Z","size":16,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-10T08:07:03.985Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/ryanhefner.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-04-24T23:07:20.000Z","updated_at":"2016-04-25T02:32:01.000Z","dependencies_parsed_at":"2022-08-31T00:31:36.712Z","dependency_job_id":null,"html_url":"https://github.com/ryanhefner/relative-time-webcomponent","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanhefner%2Frelative-time-webcomponent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanhefner%2Frelative-time-webcomponent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanhefner%2Frelative-time-webcomponent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanhefner%2Frelative-time-webcomponent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ryanhefner","download_url":"https://codeload.github.com/ryanhefner/relative-time-webcomponent/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247261584,"owners_count":20910107,"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":[],"created_at":"2024-10-01T15:35:47.322Z","updated_at":"2025-04-04T22:41:53.141Z","avatar_url":"https://github.com/ryanhefner.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `\u003crelative-time\u003e` webcomponent\n\nA [web component](https://developer.mozilla.org/en-US/docs/Web/Web_Components) used when you want to render the relative time to a date.\nIt is setup with the intention to be used like you would the `\u003ctime\u003e` element.\n\n\n## Installation\n\n`npm install relative-time-webcomponent`\n\nOr\n\n`bower install relative-time-webcomponent`\n\n## Requirements\n\nSince web components are relatively new and not widely supported by most browsers,\nthe following requirements will need to be included in your project in order for\nthis to work properly across the majority of browsers that need to be supported today.\n\n```\nnpm install document-register-element\nnpm install es6-symbol\n```\n\nAnd, for browsers that don’t natively support web components, you have to make sure\nthat you convert all the native `HTMLElement` properties to `function`s so that\nthe `document-register-element` polyfill does not bork when creating this–and possibly\nyour–custom elements.\n\n```\nif (typeof HTMLElement !== 'function') {\n    Object.getOwnPropertyNames(window).forEach((name) =\u003e {\n        if (name.indexOf('HTML') === 0) {\n            let tagName = name.replace('HTML', '').replace('Element', '').toLowerCase();\n\n            tagName = tagName.length \u0026\u0026 tagName !== 'unknown'\n                ? tagName\n                : 'div';\n\n            window[name] = () =\u003e {};\n            window[name].prototype = document.createElement(tagName);\n        }\n    });\n}\n```\n\n## Usage\n\n```\n    \u003crelative-time datetime=\"2016-04-24T19:38:00\"\u003e\u003c/relative-time\u003e\n    \u003crelative-time datetime=\"2016-04-24T19:38:00\" autoupdate\u003e\u003c/relative-time\u003e\n```\n\n## License\n\nThe MIT License (MIT)\n\nCopyright (c) 2016 Ryan Hefner [https://www.ryanhefner.com](https://www.ryanhefner.com)\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryanhefner%2Frelative-time-webcomponent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fryanhefner%2Frelative-time-webcomponent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryanhefner%2Frelative-time-webcomponent/lists"}