timeago.js v4.0 released

Memories

2 years ago , it is still based on some internal Python + bootstrap development platform. Because it involves the need to use a similar display time *** time ago, so a method implemented in Python TIMEAGO, to display the leading end after a good conversion server. Because the page international, so the built-in both Chinese and English translation.

At that time, ES6 promotion up, front-end development began frantically using React, Vue, Angular three frame, the front end can do more and more. React subscribers increased sharply stage, we try to use a platform React, and he began entering the front-end, use Python on the server to do the biggest problem that can not be calculated timeAgo dynamic rendering, because the dynamic rendering of the front or need js fit.

So, timeago.js  there, Python will translate into a set of JavaScript, then increase mechanism dynamically updated.

timeago.js is a tiny(2.0 kb) library used to format date with `*** time ago` statement.

This project is a very nano project, packing out the built-in English translation also less than 2 kb. After the open source out a few times on trending, star actually up to a thousand.

v4.0

From the beginning of version 1.0 to the current 4.0 version, in fact, not very different functions, the main change is that the code organization, API design, and technology stack updates.

v4.0 from a year and a half ago to open issue ready to start , but because of work, on weekends there is no power to write business code. But this year expanded from a lot of languages.

The main contents include:

  • ✅从 ES5 -> ES6 -> typescript
  • ✅ from a single file -> webpack Packaging -> rollup
  • ✅从 class API -> function API
  • ✅ removed jQuery support
  • ✅ extended i18n internationalization
  • ✅ single test coverage

use

Quick Start

  • installation

npm install timeago.js

  • Introduced
import { format, render, cancel, register } from 'timeago.js';

Or as in html script Tag introduction of global variables  timeago.

<script src="dist/timeago.min.js"></script>
  • example
// format the time with locale
format('2016-06-12', 'en_US');

API

  • the format : Format time time ago static string format, can be used for node environment;
  • & the Cancel the render : dynamic rendering dom label on the page;
  • the Register : Sign language locale custom;

Now includes 46 language translation . A more comprehensive use of a document, see: README.md . Demo Live: https://timeago.org .

It took a weekend day, to sort out the end of v4.0 version, but you can control two years.

Guess you like

Origin www.oschina.net/news/110547/timeago-js-4-0-released