Code Monkey home page Code Monkey logo

ms's Introduction

ms

Latest GitHub version Latest Wally version

Utility library to convert to/from milliseconds. Based on vercel/ms.

Installation

Installing with Wally

Add an entry to your wally.toml file and run wally install.

[dependencies]
ms = "csqrl/[email protected]" # Replace x.x.x with the latest version

GitHub Releases

Pre-built binaries are available on the releases page. Download the latest rbxm file and drop it into Studio.

Examples

Commas added for legibility. Actual output is an integer.

ms("2 days")    --  172,800,000
ms("1d")        --  86,400,000
ms("10h")       --  36,000,000
ms("2.5 hrs")   --  9,000,000
ms("2h")        --  7,200,000
ms("1m")        --  60,000
ms("5s")        --  5,000
ms("1y")        --  31,556,995,200
ms("100")       --  100
ms("-3 days")   -- -259,200,000
ms("-1h")       -- -3,600,000
ms("-200")      -- -200

Combine Inputs

ms("1d, 10h")                    --  122,400,000
ms("2 days, 1m")                 --  172,860,000
ms("-3days+1d")                  -- -172,860,000
ms("1y,6mo 5wks-2d 32m 1240ms")  --  49,962,116,440
ms("6 years")                    --  189,345,600,000

Convert to Seconds

ms("1 hour", "s")  -- 3,600
ms("1d", "s")      -- 86,400

Convert from Milliseconds

ms(60000)           -- "1m"
ms(2 * 60000)       -- "2m"
ms(-3 * 60000)      -- "-3m"
ms(ms("10 hours"))  -- "10h"

Convert to Long Format

ms(60000, "long")           -- "1 minute"
ms(2 * 60000, "long")       -- "2 minutes"
ms(-3 * 60000, "long")      -- "-3 minutes"
ms(ms("10 hours"), "long")  -- "10 hours"

Convert with Units

ms(60000, "short")          -- "1m"
ms(60000, "long", "s")      -- "17 hours"
ms(60, nil, "s")            -- "1 minute"
ms(1, "long", "h")          -- "1 hour"

ms's People

Contributors

cxmeel avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.