Giter VIP home page Giter VIP logo

timeago's Introduction

๐Ÿช„ TIMEAGO

Tiniest Timeago Toolbox. Supports {ago | in}. Batteries Included.

  • Localization โ€” English, Chinese, German, Spanish, French, Italian, Dutch, Japanese, Polish and Russian.
  • Prefix โ€” Add a prefix string.
  • Relative โ€” Use a relative date instead of the current time.
  • Deadline โ€” Specify a Date | string | number deadline after which a Date.toLocaleString() is displayed instead of the timeago format.
  • Seconds โ€” Set isSeconds to true if you pass a seconds timestamp. Defaults to false.
  • Close Dates - Set closeDates to true if you want to display Today/Tomorrow/Yesterday instead of the ago version. Works only for time differences between 6 hours and 1 day, other times are displayed as usual. Defaults to false.
  • Browser supported.
  • Node supported.

This package is inspired by Muffinman's blogpost. If you got some spare time, I highly recommed to check it out!

โœจ INSTALLING

Using NPM:

npm i @fetched/timeago

Using PNPM:

pnpm install @fetched/timeago

Using YARN:

yarn add @fetched/timeago

Using CDN

<script src="https://www.unpkg.com/@fetched/timeago/dist/index.umd.js"></script>

๐Ÿš€ USAGE

import { format } from '@fetched/timeago'

format(now)
// just now
format('2016-06-12')
// 7 years ago
format('2016-06-12', 'zh_CN')
// 7ๅนดๅ‰

๐ŸŒ‹ ROADMAP

  • Languages++
  • Realtime

๐Ÿ’ป DEVELOPING

Run all tests:

npm run test

Build package with microbundle for production:

npm run build

๐ŸŽจ CONTRIBUTING

Contributions for new languages are always welcome!

See examples for implementing a new language.

๐Ÿฅ‚ LICENSE

MIT License

timeago's People

Contributors

ftchd avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.