Socket
Socket
Sign inDemoInstall

moment-he

Package Overview
Dependencies
1
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    moment-he

Human Era format for moment.js


Version published
Weekly downloads
4
increased by33.33%
Maintainers
1
Install size
87.0 kB
Created
Weekly downloads
 

Readme

Source

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!

FAQs

Last updated on 11 Aug 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc