Git Product home page Git Product logo

moment-he's Introduction

moment-he

Human Era format for moment.js.

A New History for Humanity โ€“ The Human Era

Installation

yarn add moment-he

Examples

const moment = require('moment-he')

const now = moment()

// Base formats
now.humanEra('YY') // 17  (doesn't apply for short format)
now.humanEra('YYYY') // 12017
now.humanEra('Y') // 12017
now.humanEra('gggg') // 12017
now.humanEra('GGGG') // 12017

// Base formats (with suffix)
now.humanEra('YY', true) // 17
now.humanEra('YYYY', true) // 12017 HE
now.humanEra('Y', true) // 12017 HE
now.humanEra('gggg', true) // 12017 HE
now.humanEra('GGGG', true) // 12017 HE

// Localized formats
now.humanEra('L') // 08/06/12017
now.humanEra('l') // 8/6/12017
now.humanEra('LL') // August 6, 12017
now.humanEra('ll') // Aug 6, 12017
now.humanEra('LLL') // August 6, 12017 2:36 PM
now.humanEra('lll') // Aug 6, 12017 2:36 PM
now.humanEra('LLLL') // Sunday, August 6, 12017 2:36 PM
now.humanEra('llll') // Sun, Aug 6, 12017 2:36 PM

// Localized formats (with suffix)
now.humanEra('L', true) // 08/06/12017 HE
now.humanEra('l', true) // 8/6/12017 HE
now.humanEra('LL', true) // August 6, 12017 HE
now.humanEra('ll', true) // Aug 6, 12017 HE
now.humanEra('LLL', true) // August 6, 12017 HE 2:42 PM
now.humanEra('lll', true) // Aug 6, 12017 HE 2:42 PM
now.humanEra('LLLL', true) // Sunday, August 6, 12017 HE 2:42 PM
now.humanEra('llll', true) // Sun, Aug 6, 12017 HE 2:42 PM

API

The only new API is the moment().humanEra() method (also aliased as moment().he()).

It works exactly like moment().format(), the only difference being that it returns years in the Holocene Calendar instead of ISO 8601.

moment().humanEra(format[, suffix])

Arguments

  • format (string): exact same requirements as moment().format()
  • suffix (boolean): whether to display an extra 'HE' after each year, defaults to false

Output

A string, very similar to what moment().format(format) would return but with HE years!

moment-he's People

Contributors

n6g7 avatar

Stargazers

 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.