{"_id":"timediff","_rev":"25-5c7836f0cc8e1617ef6b91e81cae8645","name":"timediff","description":"Calculate a time difference in several time units.","dist-tags":{"latest":"1.1.1"},"versions":{"1.0.0":{"name":"timediff","version":"1.0.0","description":"Calculate a time difference in several time units.","main":"timediff.js","directories":{"test":"test"},"scripts":{"test":"node_modules/jasmine-node/bin/jasmine-node test/"},"repository":{"type":"git","url":"https://github.com/marcotaubmann/timediff"},"keywords":["time","moment","date","diff"],"author":{"name":"Marco Taubmann"},"license":"MIT","bugs":{"url":"https://github.com/marcotaubmann/timediff/issues"},"homepage":"https://github.com/marcotaubmann/timediff","dependencies":{"moment":"^2.9.0"},"devDependencies":{"jasmine-node":"^1.14.5"},"gitHead":"fd657c76f86d9174f5d32ed940489929d9985ace","_id":"timediff@1.0.0","_shasum":"f5723f3b4d5e5ccfb0819db619613755cbd98eac","_from":".","_npmVersion":"1.4.28","_npmUser":{"name":"marcotaubmann","email":"marco.taubmann@gmail.com"},"maintainers":[{"name":"marcotaubmann","email":"marco.taubmann@gmail.com"}],"dist":{"shasum":"f5723f3b4d5e5ccfb0819db619613755cbd98eac","tarball":"https://registry.npmjs.org/timediff/-/timediff-1.0.0.tgz","integrity":"sha512-vdgBn2qq6uDsLUl4ufl8FBnrFxMbTciaJQemCGGnsT6xAMxJhhXEut7Qx06r1+RhkaONeSIflrS+P0HU5924+w==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGdu/FECoYU3UpbuNcUfvWhSaJ+DiQSsQtcjP/GC7QdlAiBTFBa3TyEdQ0EH8XnfRVSjCijwWJjRLUY1Pp8ljnJJJg=="}]}},"1.0.1":{"name":"timediff","version":"1.0.1","description":"Calculate a time difference in several time units.","main":"timediff.js","directories":{"test":"test"},"scripts":{"test":"node_modules/jasmine-node/bin/jasmine-node test/"},"repository":{"type":"git","url":"https://github.com/marcotaubmann/timediff"},"keywords":["time","moment","date","diff"],"author":{"name":"Marco Taubmann"},"license":"MIT","bugs":{"url":"https://github.com/marcotaubmann/timediff/issues"},"homepage":"https://github.com/marcotaubmann/timediff","dependencies":{"moment":"^2.9.0"},"devDependencies":{"jasmine-node":"^1.14.5"},"gitHead":"3dd87f4b24633617b35bf2cf711d51466cebca2f","_id":"timediff@1.0.1","_shasum":"2bae0fd407d9a527b78afc1aeea62a7faff784f9","_from":".","_npmVersion":"1.4.28","_npmUser":{"name":"marcotaubmann","email":"marco.taubmann@gmail.com"},"maintainers":[{"name":"marcotaubmann","email":"marco.taubmann@gmail.com"}],"dist":{"shasum":"2bae0fd407d9a527b78afc1aeea62a7faff784f9","tarball":"https://registry.npmjs.org/timediff/-/timediff-1.0.1.tgz","integrity":"sha512-m7bco4Y3ZJxUSorrUW3dH1HUmgfNRhWm5jwjKyShwD4/yk6JCmEu/MguO27mvx8mk0jY/v3+oIK5vbU5DXESiQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIH2fVSBAQPc++vGfwHuft1MiI6hBbzQ30FkL2Sl5ckvFAiAXveOgty/O0yZQhVXXGn8wVXP121yWGyPVlwldnUMZgA=="}]}},"1.0.4":{"name":"timediff","version":"1.0.4","description":"Calculate a time difference in several time units.","main":"timediff.js","directories":{"test":"test"},"scripts":{"test":"node_modules/jasmine-node/bin/jasmine-node test/"},"repository":{"type":"git","url":"https://github.com/marcotaubmann/timediff"},"keywords":["time","moment","date","diff"],"author":{"name":"Marco Taubmann"},"license":"MIT","bugs":{"url":"https://github.com/marcotaubmann/timediff/issues"},"homepage":"https://github.com/marcotaubmann/timediff","dependencies":{"moment":"^2.9.0"},"devDependencies":{"jasmine-node":"^1.14.5"},"gitHead":"8f83bd55593d12588d142f05efb8a6309d4663e8","_id":"timediff@1.0.4","_shasum":"215eae2ad97cd2f3f0f50c3d606cc6007757cc3d","_from":".","_npmVersion":"1.4.28","_npmUser":{"name":"marcotaubmann","email":"marco.taubmann@gmail.com"},"maintainers":[{"name":"marcotaubmann","email":"marco.taubmann@gmail.com"}],"dist":{"shasum":"215eae2ad97cd2f3f0f50c3d606cc6007757cc3d","tarball":"https://registry.npmjs.org/timediff/-/timediff-1.0.4.tgz","integrity":"sha512-dpVh9hCJz/7ZxYmkIqR4eCPE9YwL4HDOwaosJ+CEqAX/tNGEEeNp6DhGiUAyaiKu8fIzsQxcNlYSyCsMbPEr5w==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDqzynZvMcP9yE0b5n3t59nOsSWszJQrg5ReujMV+8IhQIhAITqT1kplcGOXKkMgMWOpFqZTJYB++woW1d8o5d6aEbu"}]}},"1.0.5":{"name":"timediff","version":"1.0.5","description":"Calculate a time difference in several time units.","main":"timediff.js","directories":{"test":"test"},"scripts":{"test":"node_modules/jasmine-node/bin/jasmine-node test/"},"repository":{"type":"git","url":"https://github.com/marcotaubmann/timediff"},"keywords":["time","moment","date","diff"],"author":{"name":"Marco Taubmann"},"license":"MIT","bugs":{"url":"https://github.com/marcotaubmann/timediff/issues"},"homepage":"https://github.com/marcotaubmann/timediff","dependencies":{"moment":"^2.9.0"},"devDependencies":{"jasmine-node":"^1.14.5"},"gitHead":"8e645146aea97094cd58b420da11cfd5ea2ebf84","_id":"timediff@1.0.5","_shasum":"a56ae411f239cf6f88914e7bdc3fe1f47c9c71d8","_from":".","_npmVersion":"1.4.28","_npmUser":{"name":"marcotaubmann","email":"marco.taubmann@gmail.com"},"maintainers":[{"name":"marcotaubmann","email":"marco.taubmann@gmail.com"}],"dist":{"shasum":"a56ae411f239cf6f88914e7bdc3fe1f47c9c71d8","tarball":"https://registry.npmjs.org/timediff/-/timediff-1.0.5.tgz","integrity":"sha512-lvt8foS61iJpapLeoLRYgX7lcNqHEgohXO72o0JKlNUjVrVEXEp9Iv2ux4qSoluDNfbW6JqQpEcXkCo8N5nuuQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICfcQppE1t213I4RNrTy+2PnTUvsiTBN3KjeAtWUbQCKAiA4UFTRPtXUtLL61rupgo2i+9psgNo+phkoN4v1q968GQ=="}]}},"1.0.6":{"name":"timediff","version":"1.0.6","description":"Calculate a time difference in several time units.","main":"timediff.js","directories":{"test":"test"},"scripts":{"test":"node_modules/jasmine-node/bin/jasmine-node test/"},"repository":{"type":"git","url":"https://github.com/marcotaubmann/timediff"},"keywords":["time","moment","date","diff"],"author":{"name":"Marco Taubmann"},"license":"MIT","bugs":{"url":"https://github.com/marcotaubmann/timediff/issues"},"homepage":"https://github.com/marcotaubmann/timediff","dependencies":{"moment":"^2.9.0"},"devDependencies":{"jasmine-node":"^1.14.5"},"gitHead":"63aee9f01080ab15570759a97c13deb6048c04ed","_id":"timediff@1.0.6","_shasum":"3a5d754610ba41adca3b36fb37921d5b49434992","_from":".","_npmVersion":"1.4.28","_npmUser":{"name":"marcotaubmann","email":"marco.taubmann@gmail.com"},"maintainers":[{"name":"marcotaubmann","email":"marco.taubmann@gmail.com"}],"dist":{"shasum":"3a5d754610ba41adca3b36fb37921d5b49434992","tarball":"https://registry.npmjs.org/timediff/-/timediff-1.0.6.tgz","integrity":"sha512-qj8D01PdjYYSnIIm6i+2L5Ui9dX/Kb4BaPTuzMzMzjE2ENRYyeGdfN3oSq06HKVS5ZKloKqyCrCwZPyeQjAoGQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGgPZK9qOryyztHfgQJnnsU1/aZ+xTFcJ9UVQnpjJGN8AiEAvp5wk7ka6r4K1IWJkzxBbJZzp+re11Y94K5rGuH8K6s="}]}},"1.0.7":{"name":"timediff","version":"1.0.7","description":"Calculate a time difference in several time units.","main":"timediff.js","directories":{"test":"test"},"scripts":{"test":"node_modules/jasmine-node/bin/jasmine-node test/"},"repository":{"type":"git","url":"https://github.com/marcotaubmann/timediff"},"keywords":["time","moment","date","diff"],"author":{"name":"Marco Taubmann"},"license":"MIT","bugs":{"url":"https://github.com/marcotaubmann/timediff/issues"},"homepage":"https://github.com/marcotaubmann/timediff","dependencies":{"moment":"^2.9.0"},"devDependencies":{"jasmine-node":"^1.14.5"},"gitHead":"42a0296413d19d638db077cfde7e591c72bcb6be","_id":"timediff@1.0.7","_shasum":"b847edad12537bc131a5e1813d3e762b5dd5e41d","_from":".","_npmVersion":"1.4.28","_npmUser":{"name":"marcotaubmann","email":"marco.taubmann@gmail.com"},"maintainers":[{"name":"marcotaubmann","email":"marco.taubmann@gmail.com"}],"dist":{"shasum":"b847edad12537bc131a5e1813d3e762b5dd5e41d","tarball":"https://registry.npmjs.org/timediff/-/timediff-1.0.7.tgz","integrity":"sha512-/veG8glrsDs0/7//Pn2faqMe4eivFTGxbGYjpJWp2sEOfJDndYbJMoiYCGvmd4nXJA2WYfbVEqKYZLbiqEikkg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDUr6/x672tl/9XR9PfoaC65LLSmZNmVFiyXpv9TgzvKQIhAJEwgjAn2OGksYJes3O80mI8l0gCZmpAG1vF9rpSlsid"}]}},"1.1.0":{"name":"timediff","version":"1.1.0","description":"Calculate a time difference in several time units.","author":{"name":"Marco Taubmann"},"license":"MIT","main":"timediff.js","engines":{"node":">=0.10.0"},"bin":{"timediff":"cli.js"},"scripts":{"test":"node_modules/jasmine-node/bin/jasmine-node test/"},"keywords":["time","moment","date","diff"],"homepage":"https://github.com/marcotaubmann/timediff","bugs":{"url":"https://github.com/marcotaubmann/timediff/issues"},"repository":{"type":"git","url":"https://github.com/marcotaubmann/timediff"},"dependencies":{"moment":"^2.9.0"},"devDependencies":{"jasmine-node":"^1.14.5"},"gitHead":"a9c6354f89ba464477dab1b905da00b1751eb8e9","_id":"timediff@1.1.0","_shasum":"5761ad5a1709df7af6ea8191370d943f89ab6c71","_from":".","_npmVersion":"1.4.28","_npmUser":{"name":"marcotaubmann","email":"marco.taubmann@gmail.com"},"maintainers":[{"name":"marcotaubmann","email":"marco.taubmann@gmail.com"}],"dist":{"shasum":"5761ad5a1709df7af6ea8191370d943f89ab6c71","tarball":"https://registry.npmjs.org/timediff/-/timediff-1.1.0.tgz","integrity":"sha512-ODmNjHAICkh/V6spGR+VloOFXUCFS5hRWK4nVfV1y3svDl1s/rP1U0U29FEmRPGBmgEu0B2svvPzSPTUDBny6Q==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGgNh1fdKIgjBgbNc5OatxU5q4H3Dgv5bdHcmDVuoJxzAiAgDM4xn4rZqUAikHzCRsVUnvOUqpqcF04iNiZi+pIZ8w=="}]}},"1.1.1":{"name":"timediff","version":"1.1.1","description":"Calculate a time difference in several time units.","author":{"name":"Marco Taubmann"},"license":"MIT","main":"timediff.js","engines":{"node":">=0.10.0"},"bin":{"timediff":"cli.js"},"scripts":{"test":"node_modules/jasmine-node/bin/jasmine-node test/"},"keywords":["time","moment","date","diff"],"homepage":"https://github.com/marcotaubmann/timediff","bugs":{"url":"https://github.com/marcotaubmann/timediff/issues"},"repository":{"type":"git","url":"https://github.com/marcotaubmann/timediff"},"dependencies":{"moment":"^2.9.0"},"devDependencies":{"jasmine-node":"^1.14.5"},"gitHead":"e861f219c1744bbabf5230def91a22615b2fcfc9","_id":"timediff@1.1.1","_shasum":"66437af9b094022711e7de850ecb00a9f3407d38","_from":".","_npmVersion":"1.4.28","_npmUser":{"name":"marcotaubmann","email":"marco.taubmann@gmail.com"},"maintainers":[{"name":"marcotaubmann","email":"marco.taubmann@gmail.com"}],"dist":{"shasum":"66437af9b094022711e7de850ecb00a9f3407d38","tarball":"https://registry.npmjs.org/timediff/-/timediff-1.1.1.tgz","integrity":"sha512-0jw2uAy2Wc+tlKo/puWa2U20NwGkadyh0qSxz/paWWay1dR+4V82BQJ4/s+ebk89tN/+W2Al5YZp7K6cVTDevg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC2BkNsffyjvbohzjUkuGa9GNHbkZgjuprNU0LCnp1EQwIhAIwoDXAbmToLyEjvWfT8baNdrKKOUF1SayxfLPhecoUZ"}]}}},"readme":"# timediff\nCalculate a time difference in several time units.\n\n## Usage\n\n### Node\n\n```sh\n$ npm install --save timediff\n```\n\n```js\nvar timediff = require('timediff');\n\ntimediff('2015-01-01', '2018-05-02 02:15:10.777', 'YDHms');\n// => { years: 3, days: 121, hours: 2, minutes: 15, milliseconds: 10777 }\n```\n\n### Bower\n\n```sh\n  bower install --save timediff\n```\n\n```html\n  <code id=\"result\"></code>\n  <script src=\"bower_components/moment/moment.js\"></script>\n  <script src=\"bower_components/timediff/timediff.js\"></script>\n  <script>\n    (function showResult () {\n      var result = timediff('2015-01-01', '2018-05-02 02:15:10.777', 'YDHms');\n      console.log(result);\n      document.getElementById('result').innerHTML = JSON.stringify(result);\n    })();\n  </script>\n```\n\n### CLI\n```sh\n$ npm install --global timediff\n```\n\n```sh\n$ timediff --help\n\n   Usage: timediff <start> <end> [<units>]\n\n   Example:\n\n     timediff 2013-12-01 '2015-04-20 12:20:10.342' YMWDHmSs\n     years: 1\n     months: 4\n     weeks: 2\n     days: 5\n     hours: 12\n     minutes: 20\n     seconds: 10\n     milliseconds: 342\n\n     timediff 1989-11-09 now YD\n     years: 25\n     days: 71\n```\n\n## Examples\n\n```js\n// return the timediff in all possible units\ntimediff(new Date(2015, 1, 1), new Date('2018-05-02 02:15:10'));\n// => { years: 3, months: 3, weeks: 0, days: 1, hours: 2, minutes: 15, seconds: 10, milliseconds: 0 }\n\n// return the timediff only in years, weeks, days hours and seconds\ntimediff(new Date(2015, 1, 1), new Date('2018-05-02 02:15:10.777'), 'YWDHS');\n// => { years: 3, weeks: 12, days: 6, hours: 2, seconds: 910 }\n\n// return the timediff only in month, minutes seconds, and milliseconds\ntimediff(new Date(2015, 1, 1), new Date('2018-05-02 02:15:10.777'), 'MmSs');\n// => { months: 39, minutes: 1575, seconds: 10, milliseconds: 777 }\n\n// provide the result to a callback and return the result of the callback\ntimediff('1969-06-09T06:09:06.069Z', new Date(), function (result) {\n  var strings = [];\n  for(var key in result) {\n    strings.push(result[key] + ' ' + key);\n  }\n  return 'age: ' + strings.join(', ');\n});\n// => 'age: 45 years, 7 months, 0 weeks, 6 days, 5 hours, 54 minutes, 5 seconds, 257 milliseconds'\n\n// combine all options\nvar christmas = new Date(); christmas.setMonth(11); christmas.setDate(24);\ntimediff(new Date(), christmas, {\n  units: 'MWD',\n  returnZeros: false,\n  callback: function (result) {return 'Time until christmas: ' + JSON.stringify(result);}\n});\n// => 'Time until christmas: {\"months\":11,\"weeks\":1,\"days\":1}'\n```\n\n## API\n\n### timediff(start, end, options)\n\nReturn the time difference between `start` and `end`. Use only the units specified in `options`.\n\nReturn:\n```js\n{\n  years: 0,\n  months: 0,\n  weeks: 0,\n  days: 0,\n  hours: 0,\n  minutes: 0,\n  seconds: 0,\n  milliseconds: 0\n}\n```\n\n#### start, end\n\n*Required*\nType: `string` | `Date` | `moment`\n\n#### options\n\nType: `object` | `string` | `function`\n\nDefault:\n```js\n{\n  units: {\n    years:true,\n    months: true,\n    weeks: true,\n    days: true,\n    hours: true,\n    minutes: true,\n    seconds: true,\n    milliseconds: true\n  },\n  returnZeros: true,\n  callback: null\n}\n```\n\nUse `timediff(start, end, unitString)` (where `unitString` is a string) as a shortcut for\n`timediff(start, end, {units: unitString})`.\n\nUse `timediff(start, end, callback)` (where `callback` is a function) as a shortcut for\n`timediff(start, end, {callback: callback})`.\n\n##### options.units\n\nType: `object` | `string`\n  \nCan be an object as given above or a string containing any of `YMWDHmSs`.\nIf a letter exists in the string the corresponding unit is used in\nthe result.\n\n| letter | result uses  |\n| ------ | -------------|\n| Y      | years        |\n| M      | months       |\n| W      | weeks        |\n| D      | days         |\n| H      | hours        |\n| m      | minutes      |\n| S      | seconds      |\n| s      | milliseconds |\n\n##### options.returnZeros\n\nType: boolean\n\nIf `true` result can contain fields that are `0`, if `false` they are removed.\n\n##### options.callback\n\nType: `function`\n\nFunction that is called with the result of timediff as the first parameter.\ntimediff returns the return value of this callback.\n\n## Licence\nMIT copyright [Marco Taubmann]\n","maintainers":[{"name":"marcotaubmann","email":"marco.taubmann@gmail.com"}],"time":{"modified":"2022-06-27T06:46:46.047Z","created":"2015-01-15T14:33:28.623Z","1.0.0":"2015-01-15T14:33:28.623Z","1.0.1":"2015-01-15T14:41:02.919Z","1.0.4":"2015-01-15T21:08:04.998Z","1.0.5":"2015-01-15T21:12:38.685Z","1.0.6":"2015-01-15T21:17:43.568Z","1.0.7":"2015-01-16T14:27:39.808Z","1.1.0":"2015-01-19T14:27:19.982Z","1.1.1":"2015-01-19T14:52:32.181Z"},"homepage":"https://github.com/marcotaubmann/timediff","keywords":["time","moment","date","diff"],"repository":{"type":"git","url":"https://github.com/marcotaubmann/timediff"},"author":{"name":"Marco Taubmann"},"bugs":{"url":"https://github.com/marcotaubmann/timediff/issues"},"license":"MIT","readmeFilename":"README.md","users":{"sfomin":true,"prestorondo":true,"martinspinks":true,"abhisekp":true,"letsbora":true}}