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

fluent-date

v1.0.2

Published

A multi-language (Chinese, English) fluent date parser (relative time, duration).

Downloads

1

Readme

fluent-date

npm version npm downloads

支持 TypeScript,JavaScript 的多语言通顺时间翻译器

A multi-language (Chinese, English) fluent date parser with native TypeScript and JavaScript support.

Format a date to:

  • just now
  • 3 seconds ago
  • 6 minutes ago
  • 1 hour ago
  • 2 weeks ago
  • 4 months ago
  • 5 years ago

支持中文:

  • 刚刚
  • 3 秒前
  • 6 分钟前
  • 1 小时前
  • 2 周前
  • 4 月前
  • 5 年前

Limitation

Those are the limitations for the latest version. Those features will be released in the future

  1. Only support English and Chinese for now
  2. Only support past dates (will be in the next version)
  3. Only support built-in phrases. (Customization will be released soon)

Install

$ npm install fluent-date

Usage

TypeScript

import { FluentDate, Language } from "fluent-date";

// English
const enFd = new FluentDate(); // The default language is English

console.log(enFd.relative(Date.now() - 60 * 1000 + 1)); // 59 seconds ago
console.log(enFd.relative(Date.now())); // just now

// Chinese
const zhFd = new FluentDate(Language.ZH);
console.log(zhFd.relative(Date.now() - 7200 * 1000 + 1)); // 1 小时前
console.log(zhFd.relative(Date.now())); // 刚刚

JavaScript

const { FluentDate, Language } = require("fluent-date");

// English
const enFd = new FluentDate(); // The default language is English

console.log(enFd.relative(Date.now() - 60 * 1000 + 1)); // 59 seconds ago
console.log(enFd.relative(Date.now())); // just now

// Chinese
const zhFd = new FluentDate(Language.ZH);
console.log(zhFd.relative(Date.now() - 7200 * 1000 + 1)); // 1 小时前
console.log(zhFd.relative(Date.now())); // 刚刚

Upcoming features

自定义时间尺度 Configurable time scale

多语言支持 Multi-language support

  1. 中文 Chinese
  2. 英文 English
  3. 日文 Japanese (wip)
  4. 佛文 Buddism(wip)

Bug reports

Please open an issue describing your bug.

Feature requests

Please open an issue for new feature requests.