Git Product home page Git Product logo

human-units-formatter's Introduction

Human Unit Formatter

Duration Formatter

Parameter Default Description
value The integer value to format
start_unit 's' The unit of the value parameter, one of ms, s, m, h, d
precision 's' The smallest unit to display, one of ms, s, m, h, d

Examples:

fmt_human_duration(-10) == '0s'
fmt_human_duration(10_000, start_unit='ms') == '10s'
fmt_human_duration(60 * 60 * 24 + 23) == '1d 23s'
fmt_human_duration(60 * 60 * 24 + 23, precision='h') == '1d'

Size Formatter

Parameter Default Description
value The integer value to format
unit '' E.g. B, iB, B/s, Hz
factor 1000 Pass 1024 for binary transformation (1024 B = 1 KiB)
start_prefix '' if the value parameter is preformatted, pass one of K, M, G,T, P,E, Z, Y

Examples:

fmt_human_size(100, unit='B/s') == '100 B/s'
fmt_human_size(1025, factor=1024, unit='iB') == '1 KiB'
fmt_human_size(1200, unit='Hz', start_prefix='M') == '1.2 GHz'
fmt_human_size(5_000, unit='B', start_prefix='K') == '5 MB'

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.