Code Monkey home page Code Monkey logo

angular-timeago's Introduction

angular-timeago Analytics

Angular directive/filter/service for formatting date so that it displays how long ago the given time was compared to now.

Disclaimer

This project is based off of a thread on Angular Google Groups. The person who started the thread, @lrlopez, gave me permission to start a repo using the code he wrote initially. Thanks to @lrlopez and other contributors in the thread.

Demo

Check out the demo here.

Usage

Install via Bower

bower install --save angular-timeago

Reference in module

var app = angular.module('ngApp', [
  'yaru22.angular-timeago'
]);

Filter

{{myDate | timeAgo}}

Displays time ago since myDate. myDate can be time in milliseconds since January 1st 1970 (see MDN Date.prototype.getTime) or an ISO 8601 string (see MDN Date.prototype.toISOString)

Language support angular-timeago currently supports: en_US, de_DE, he_IL, pt_BR. If you want more languages: feel free to contribute! The language is determined by the string in document.documentElement.lang which you can set in your HTML markup:

<html lang="en_US"></html>

Or directly in JS:

window.document.documentElement.lang = 'en_US';

You can also add additional or alter existing languages at runtime by extending the service:

timeAgo.settings.strings.en_US = {
  // appropriate keys here
};

For more details refer to the source code.

Testing

In order to run the e2e tests you might need to install a Selenium server via:

./node_modules/grunt-protractor-runner/scripts/webdriver-manager-update```

And then use grunt to run all tests (unit and e2e):

grunt test

angular-timeago's People

Contributors

yaru22 avatar kalbasit avatar thunder-dan avatar fmoliveira avatar leonzinger avatar olegdater avatar carlos avatar ilgianfra avatar maikelsgit avatar jcsena avatar simokhalil avatar pilwon avatar w3blogfr avatar

Watchers

James Cloos avatar  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.