Have ideas to improve npm?Join in the discussion! »

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

    1.1.1 • Public • Published

    NPM Version CI codecov Dev Dependency Status

    Time Value

    An immutable library for parsing and manipulating an amount of time.

    Time represents an amount of time (2hrs), not a time of day (2pm). Thus, Time can be negative (-02:30:00) and greater than 24 hours (52:30:00). It pairs nicely with MySQL's time data type.

    Table of Contents

    Features

    • 🎉 Immutable API.
    • 💪 Written in TypeScript.
    • 🚀 Zero dependencies.

    Installation

    npm install time-value --save

    Usage

    import { Time } from 'time-value';
    
    const time1 = Time.parse('02:30:10');
    // => 2 hrs, 30 mins, and 10 secs
    
    const time2 = new Time(5, 8, 30);
    // => 5 hrs, 8 mins, and 30 secs
    
    const time3 = time1.add(time2);
    // => 7 hrs, 38 mins, 40 secs
    
    const time4 = Time.sum(['05:30:00', '03:45:15']);
    // => 9 hrs, 15 mins, and 15 secs

    Development

    npm install
    npm run build
    

    Install

    npm i time-value

    DownloadsWeekly Downloads

    32

    Version

    1.1.1

    License

    MIT

    Unpacked Size

    29.9 kB

    Total Files

    10

    Last publish

    Collaborators

    • avatar