{"id":27464801,"url":"https://github.com/codebox/moment-precise-range","last_synced_at":"2025-04-15T23:15:45.077Z","repository":{"id":14378142,"uuid":"17088252","full_name":"codebox/moment-precise-range","owner":"codebox","description":"A moment.js plugin to display human-readable date/time ranges","archived":false,"fork":false,"pushed_at":"2018-04-17T15:20:32.000Z","size":55,"stargazers_count":151,"open_issues_count":9,"forks_count":89,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-04-15T23:15:39.580Z","etag":null,"topics":["javascript","moment","moment-library","range"],"latest_commit_sha":null,"homepage":"https://codebox.net/pages/moment-date-range-plugin","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/codebox.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":"2014-02-22T16:04:42.000Z","updated_at":"2025-03-23T18:03:49.000Z","dependencies_parsed_at":"2022-09-05T17:00:27.271Z","dependency_job_id":null,"html_url":"https://github.com/codebox/moment-precise-range","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/codebox%2Fmoment-precise-range","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codebox%2Fmoment-precise-range/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codebox%2Fmoment-precise-range/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codebox%2Fmoment-precise-range/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codebox","download_url":"https://codeload.github.com/codebox/moment-precise-range/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249167457,"owners_count":21223508,"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":["javascript","moment","moment-library","range"],"created_at":"2025-04-15T23:15:44.579Z","updated_at":"2025-04-15T23:15:45.069Z","avatar_url":"https://github.com/codebox.png","language":"JavaScript","readme":"# moment-precise-range\n\nThis is a plugin for the \u003ca href=\"http://momentjs.com/\"\u003emoment.js\u003c/a\u003e JavaScript library, to display date/time ranges precisely, in a human-readable format.\n\nMoment already contains some support for formatting date/time ranges, however it performs a lot of 'rounding' on the result and yields only an approximate description.\n \nIn the example below the difference between the 2 dates is 1 month, 2 days, 3 hours, 4 minutes and 5 seconds exactly, however this is simplified to just 'a month' by the library. \n\n    var m1 = moment('2014-01-01 12:00:00','YYYY-MM-DD HH:mm:ss');\n    var m2 = moment('2014-02-03 15:04:05','YYYY-MM-DD HH:mm:ss');\n    var diff = moment.duration(m1.diff(m2)).humanize(); // 'a month'\n\nUsing the plugin, we can display the exact difference using the same 2 dates:\n\n    var m1 = moment('2014-01-01 12:00:00','YYYY-MM-DD HH:mm:ss');\n    var m2 = moment('2014-02-03 15:04:05','YYYY-MM-DD HH:mm:ss');\n    var diff = moment.preciseDiff(m1, m2); // '1 month 2 days 3 hours 4 minutes 5 seconds'\n\nTo obtain the numeric values rather than a string, pass the value `true` as the third argument to the method:\n\n    var diff = moment.preciseDiff(m1, m2, true); // {years : 0, months : 1, days : 2, hours : 3, minutes : 4, seconds : 5}\n\n## Usage\n\n### HTML/Browser\n\nTo use the plugin in a web page, add a `\u003cscript\u003e` tag referencing the moment-precise-range.js file, ensuring that the tag appears \nafter the tag used to include the moment.js library:\n\n    \u003cscript src=\"/scripts/moment.js\"\u003e\u003c/script\u003e\n    \u003cscript src=\"/scripts/moment-precise-range.js\"\u003e\u003c/script\u003e\n\n### Node.js\n\nTo use the plugin within a node.js application, add the following `require` statement into your code:\n\n    require('moment-precise-range-plugin');\n\nYou can try out the Node package online at \u003ca href=\"https://tonicdev.com/npm/moment-precise-range-plugin\"\u003etonicdev\u003c/a\u003e","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodebox%2Fmoment-precise-range","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodebox%2Fmoment-precise-range","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodebox%2Fmoment-precise-range/lists"}