pax_global_header00006660000000000000000000000064126605570230014520gustar00rootroot0000000000000052 comment=4bf8c19fa84efca958f3823f794f0d55c49e5827 parse-ms-1.0.1/000077500000000000000000000000001266055702300132465ustar00rootroot00000000000000parse-ms-1.0.1/.editorconfig000066400000000000000000000003371266055702300157260ustar00rootroot00000000000000root = true [*] indent_style = tab end_of_line = lf charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true [package.json] indent_style = space indent_size = 2 [*.md] trim_trailing_whitespace = false parse-ms-1.0.1/.gitattributes000066400000000000000000000000141266055702300161340ustar00rootroot00000000000000* text=auto parse-ms-1.0.1/.gitignore000066400000000000000000000000151266055702300152320ustar00rootroot00000000000000node_modules parse-ms-1.0.1/.jshintrc000066400000000000000000000002761266055702300151000ustar00rootroot00000000000000{ "node": true, "esnext": true, "bitwise": true, "camelcase": true, "curly": true, "immed": true, "newcap": true, "noarg": true, "undef": true, "unused": "vars", "strict": true } parse-ms-1.0.1/.travis.yml000066400000000000000000000001101266055702300153470ustar00rootroot00000000000000sudo: false language: node_js node_js: - 'iojs' - '0.12' - '0.10' parse-ms-1.0.1/index.js000066400000000000000000000006411266055702300147140ustar00rootroot00000000000000'use strict'; module.exports = function (ms) { if (typeof ms !== 'number') { throw new TypeError('Expected a number'); } var roundTowardZero = ms > 0 ? Math.floor : Math.ceil; return { days: roundTowardZero(ms / 86400000), hours: roundTowardZero(ms / 3600000) % 24, minutes: roundTowardZero(ms / 60000) % 60, seconds: roundTowardZero(ms / 1000) % 60, milliseconds: roundTowardZero(ms) % 1000 }; }; parse-ms-1.0.1/license000066400000000000000000000021371266055702300146160ustar00rootroot00000000000000The MIT License (MIT) Copyright (c) Sindre Sorhus (sindresorhus.com) Permission 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: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE 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. parse-ms-1.0.1/package.json000066400000000000000000000011041266055702300155300ustar00rootroot00000000000000{ "name": "parse-ms", "version": "1.0.1", "description": "Parse milliseconds into an object", "license": "MIT", "repository": "sindresorhus/parse-ms", "author": { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", "url": "http://sindresorhus.com" }, "engines": { "node": ">=0.10.0" }, "scripts": { "test": "mocha" }, "files": [ "index.js" ], "keywords": [ "browser", "parse", "time", "ms", "milliseconds", "duration", "period", "range" ], "devDependencies": { "mocha": "*" } } parse-ms-1.0.1/readme.md000066400000000000000000000006251266055702300150300ustar00rootroot00000000000000# parse-ms [![Build Status](https://travis-ci.org/sindresorhus/parse-ms.svg?branch=master)](https://travis-ci.org/sindresorhus/parse-ms) > Parse milliseconds into an object ## Install ```sh $ npm install --save parse-ms ``` ## Usage ```js parseMs(1337000001); //=> { days: 15, hours: 11, minutes: 23, seconds: 20, milliseconds: 1 } ``` ## License MIT © [Sindre Sorhus](http://sindresorhus.com) parse-ms-1.0.1/test.js000066400000000000000000000030431266055702300145630ustar00rootroot00000000000000'use strict'; var assert = require('assert'); var parseMs = require('./'); it('should parse milliseconds into an object', function () { assert.deepEqual(parseMs(1000 + 400), { days: 0, hours: 0, minutes: 0, seconds: 1, milliseconds: 400 }); assert.deepEqual(parseMs(1000 * 55), { days: 0, hours: 0, minutes: 0, seconds: 55, milliseconds: 0 }); assert.deepEqual(parseMs(1000 * 67), { days: 0, hours: 0, minutes: 1, seconds: 7, milliseconds: 0 }); assert.deepEqual(parseMs(1000 * 60 * 5), { days: 0, hours: 0, minutes: 5, seconds: 0, milliseconds: 0 }); assert.deepEqual(parseMs(1000 * 60 * 67), { days: 0, hours: 1, minutes: 7, seconds: 0, milliseconds: 0 }); assert.deepEqual(parseMs(1000 * 60 * 60 * 12), { days: 0, hours: 12, minutes: 0, seconds: 0, milliseconds: 0 }); assert.deepEqual(parseMs(1000 * 60 * 60 * 40), { days: 1, hours: 16, minutes: 0, seconds: 0, milliseconds: 0 }); assert.deepEqual(parseMs(1000 * 60 * 60 * 999), { days: 41, hours: 15, minutes: 0, seconds: 0, milliseconds: 0 }); }); it('should handle negative millisecond values', function () { [ 100 + 400, 1000 * 55, 1000 * 67, 1000 * 60 * 5, 1000 * 60 * 67, 1000 * 60 * 60 * 12, 1000 * 60 * 60 * 40, 1000 * 60 * 60 * 999 ].forEach(function (ms) { var positive = parseMs(ms); var negative = parseMs(-ms); [ 'days', 'hours', 'minutes', 'seconds', 'milliseconds' ].forEach(function (key) { assert.equal(negative[key], -positive[key]); }); }); });