space-time
TypeScript icon, indicating that this package has built-in type declarations

1.1.1 • Public • Published

Human readable data size and time calculations.

import {bytes, ms} from 'space-time';

bytes('1mb');
bytes('12.5Mb');
bytes('1 gigabyte + 12MB');

ms('1h');
ms('1 hr and 30 mins');
ms('52w 5h 1d');
ms('52 weeks, 5 hours and 1 day to be precise');

Time functions support Date.now() relative calculations:

ms.now('+1 week'); // Date.now() + ms('1 week')
seconds.now('-7 days'); // seconds(Date.now() - ms('7 days'))

Other size/time conversion units available:

kilobytes('50 mb');
megabytes('100gb');
gigabytes('50 terabytes + 512mb');
terabytes('500mb');

seconds('1 year');
minutes('10 days');
hours('10000 seconds');
days('5.5 years');
weeks('49 days');
years('3 lunar months and 1024 days');

Dependencies (0)

    Dev Dependencies (3)

    Package Sidebar

    Install

    npm i space-time

    Weekly Downloads

    183

    Version

    1.1.1

    License

    MIT

    Unpacked Size

    27.4 kB

    Total Files

    13

    Last publish

    Collaborators

    • pete_b