All Projects → martinandert → react-ago-component

martinandert / react-ago-component

Licence: MIT License
A component for React that renders the approximate time ago in words from a specific past date using an HTML5 time element.

Programming Languages

javascript
184084 projects - #8 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to react-ago-component

edtf.js
Extended Date Time Format (ISO 8601-2 / EDTF) Parser for JavaScript
Stars: ✭ 44 (+76%)
Mutual labels:  time, date
chronos
One library to rule the time
Stars: ✭ 17 (-32%)
Mutual labels:  time, date
popoPicker
popoPicker是一个移动端3D滚轮日期时间和单项的选择器,支持无限循环滚动,不依赖第三方库
Stars: ✭ 26 (+4%)
Mutual labels:  time, date
date4j
Lightweight alternative to Java's built-in date-time classes. Android-friendly. Compiles under JDK 1.5.
Stars: ✭ 36 (+44%)
Mutual labels:  time, date
moment-cache
⏱ Simple utility to cache moment.js results and speed up moment calls.
Stars: ✭ 29 (+16%)
Mutual labels:  time, date
shamsi date
A Flutter and Dart package for using Jalali (Shamsi, Solar, Persian or Jalaali) calendar. You can convert, format and manipulate Jalali and Gregorian (Miladi) date and times.
Stars: ✭ 59 (+136%)
Mutual labels:  time, date
dayjs
Extended fork of Day.js - 2KB immutable date library alternative to Moment.js
Stars: ✭ 36 (+44%)
Mutual labels:  time, date
go-systemd-time
📅 Go implementation of systemd relative time adjustments
Stars: ✭ 21 (-16%)
Mutual labels:  time, date
date-php
这是一个Javascript模仿PHP日期时间格式化函数,使用方法和PHP非常类似,有丰富的模板字符,并在原来的基础上增加了一些模板字符。 This is a date function that implement PHP in Javascript. It is very similar to PHP, has rich template characters, and enhances some template characters on the basis of the original.
Stars: ✭ 24 (-4%)
Mutual labels:  time, date
react-picky-date-time
A react component for date time picker. Online demo examples
Stars: ✭ 41 (+64%)
Mutual labels:  time, date
dt
Go's missing DateTime package
Stars: ✭ 34 (+36%)
Mutual labels:  time, date
react-daterange-picker
A react date range picker to using @material-ui. Live Demo: https://flippingbitss.github.io/react-daterange-picker/
Stars: ✭ 85 (+240%)
Mutual labels:  date, react-component
vue-translated
Internationalization (i18n) and localization (l10n) library for Vue.js v2.
Stars: ✭ 19 (-24%)
Mutual labels:  time, date
relative.time.parser
Moment.js Plugin for parsing Relative Time Strings
Stars: ✭ 13 (-48%)
Mutual labels:  time, date
hs-hourglass
efficient and simpler time API for haskell
Stars: ✭ 43 (+72%)
Mutual labels:  time, date
time-formater
在javascript中显示日期。
Stars: ✭ 44 (+76%)
Mutual labels:  time, date
qrono
🕥 Just right date time library
Stars: ✭ 111 (+344%)
Mutual labels:  time, date
rutimeparser
Recognize date and time in russian text and return datetime.datetime.
Stars: ✭ 17 (-32%)
Mutual labels:  time, date
rescript-date
📆 Date manipulation in ReScript.
Stars: ✭ 101 (+304%)
Mutual labels:  time, date
vue-timeselector
🕒 Simply customizable powerful time picker for Vue.js
Stars: ✭ 41 (+64%)
Mutual labels:  time, date

React Ago Component

A multi-lingual component for React that renders the approximate time ago in words from a specific past date using an HTML5 time element.

Features:

  • configurable to auto-update its display as time passes by
  • supports localized output (with the help of Counterpart and Damals)

Installation

Install via npm:

% npm install react-ago-component

Usage

Just require and render:

var Ago  = require('react-ago-component');
var then = new Date('Sat Mar 06 1976 04:05:09 GMT+0100 (CET)');

// render component with
Ago({ date: then });  // JSX: <Ago date={then} />

This will output something in the likes of

<time datetime="1976-03-06T04:05:09+01:00" title="Sat, 6 Mar 1976 04:05">about 38 years ago</time>

The date prop can be set to a Date object, a number holding the milliseconds since Unix epoch, or to a string (which will be parsed as a Date).

There is also a tooltipFormat prop to configure the verbosity of the HTML title attribute. Valid values are "short", "long", and "default" (somewhere in-between).

If you want your page to auto-update the visible portion of the rendered HTML element as time passes by, just set the autoUpdate prop to true. You can also provide an update interval (in seconds) by setting the prop's value to a natural number greater than 0.

Localization Support

To localize the rendered output for a locale other than "en" (English), load the corresponding translations and set the locale using Counterpart and Damals:

counterpart.registerTranslations('de', require('counterpart/locales/de'));
counterpart.registerTranslations('de', require('damals/locales/de'));

counterpart.setLocale('de');

When switching locales the Ago component will auto-adjust its output (no page reloading necessary).

Example

The examples code is located at the example directory. You can clone this repository and run make install example and point your web browser to http://localhost:3000.

Contributing

Here's a quick guide:

  1. Fork the repo and make install.

  2. Run the tests. We only take pull requests with passing tests, and it's great to know that you have a clean slate: make test.

  3. Add a test for your change. Only refactoring and documentation changes require no new tests. If you are adding functionality or are fixing a bug, we need a test!

  4. Make the test pass.

  5. Push to your fork and submit a pull request.

Licence

Released under The MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].