npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-shi

v0.4.2

Published

It's a lib which let you to transfer human time to computer-readable time and also to transfer computer-generated time to human time, available for English and Chinese words.

Downloads

29

Readme

node-shi(时)

It's a lib which let you to transfer human time to computer-readable time and also to transfer computer-generated time to human time, available for English and Chinese.

NPM Package | CNPM

How to use

# npm
npm i node-shi

# yarn
yarn add node-shi
var shi = require('node-shi');

// human time -> time in Arabic number as seconds
console.log(shi.humanTimeParser("five hundreds and twenty one seconds"));//521
console.log(shi.humanTimeParser("a day and 一 hour, 52 min 16sec"));//93136
console.log(shi.humanTimeParser("三十三分钟", { to: "m" }));//33
shi.setDefault({ as: 'm' });//set default
console.log(shi.humanTimeParser("50", { to: 'h' }))//0.8333333333333334
console.log(shi.humanTimeParser("50", { as: 'h', to: 'm' }))//3000
shi.clearDefault();//clear defaults
console.log(shi.humanTimeParser("badstring", { ignoreError: true }))//badstring (because errors ignored)

// unit convert
console.log(shi.unitConverter(60, 'm', 'h'));//1
console.log(shi.unitConverter(1, "d", "ms"));//86400000

// time in Arabic number -> human time
console.log(shi.ArabicNumberTimeParser(1500));//25 minutes
console.log(shi.ArabicNumberTimeParser(36, { lang: 'fr', to: 'h' }));//0,01 heure
console.log(shi.ArabicNumberTimeParser(1, { lang: 'zh_CN', as: 'ms', to: 's', round: true }));//0 秒
console.log(shi.ArabicNumberTimeParser(NaN, { ignoreError: true }))//0 seconds (because errors ignored)

// output the version
console.log(shi.version());//0.4.2

Features

Human time -> time in Arabic number

  • Chinese number + Chinese unix -> time in Arabic number as seconds
  • Chinese number + English unix -> time in Arabic number as seconds
  • Arabic number + Chinese unix -> time in Arabic number as seconds
  • Arabic number + English unix -> time in Arabic number as seconds
  • English number + Chinese unix -> time in Arabic number as seconds
  • English number + English unix -> time in Arabic number as seconds

Time in Arabic number -> Human time

  • Time with units d, h, m (min), s, ms to human time in languages including: 'ar', 'bg', 'ca', 'cs', 'da', 'de', 'el', 'en', 'es', 'et', 'fa', 'fi', 'fo', 'fr', 'he', 'hr', 'hu', 'id', 'is', 'it', 'ja', 'ko', 'lo', 'lt', 'lv', 'ms', 'nl', 'no', 'pl', 'pt', 'ro', 'ru', 'uk', 'ur', 'sk', 'sv', 'tr', 'th', 'vi', 'zh_CN', 'zh_TW'.

Time unix translate

  • Arabic number in different unixs d, h, m (min), s, ms -> time in Arabic number as d, h, m (min), s, ms

Future of this project

For the future of node-shi, go to the todo-list.

Packages Using

  • js-pinyin, waterchestnet, MIT License.
  • timestring, mike182uk, MIT License.
  • chinese-numbers-converter, anton-bot, MIT License.
  • english2number, TSavo, MIT License.
  • HumanizeDuration.js, EvanHahn, Unlicense.