Code Monkey home page Code Monkey logo

sublime-formatter's Introduction

A mini tool for formatting dates, currencies, and relative times.

Project Status

sublime-formatter is a beta test tool. You can contribute to the evolution.

Thank you.

Resources

Install

$ npm install sublime-formatter --save 

Import

const format = require('sublime-formatter')

Examples

toCurrency

// first parameter: number (required), Must be an integer
// second parameter: currency (default 'XAF' => Franc CFA BEAC), You can put 'USD' => American Dollars, 'EUR' => Euro, ...
// third parameter: local (default 'fr' => French), You can put 'en' or 'en-EN' => English  Great Britain, 'fr-CA' french Canada, ...
format.toCurrency(15000);
// Output: 15 000 FCFA

relativeTime

// first parameter: time (required), Must be an positive or negative number
// second parameter: unit (default 'day'), You can put 'month', 'week', ...
format.relativeTime(2);
// Output: après-demain
format.relativeTime(-1);
// Output: hier

formatDate

// first parameter: date (required)
// second parameter: format (default null), see the following formats
format.formatDate(new Date());
// Output: 21 août 2022
format.formatDate(new Date(), 'L');
// Output: 21 août 2022, 23:21

default formats

// d: 30,
// m: 08,
// mt: Aug,
// M: August,
// y: 2022,
// LTS: 02:10:24,
// LT: 02:10,
// L: Aug 30, 2022,
// LL: August 30, 2022,
// LLL: August 30, 2022, 02:10,
// LLLL: August 30, 2022, 02:12:06 GMT,

sublime-formatter's People

Contributors

thecodemaker12 avatar

Stargazers

 avatar 3S TECH GROUP 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.