Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ember-moment

Package Overview
Dependencies
Maintainers
6
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ember-moment

Moment.js template helpers and computed property macros for Ember

  • 3.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
30K
increased by5.15%
Maintainers
6
Weekly downloads
 
Created
Source

Ember-moment

npm Version Build Status

moment.js template helpers for ember

Requirements

  • Ember >= 1.10
    • If you need support for < Ember 1.10 please use ember-moment 1.x-2.x
  • HTMLBars

Usage

  • ember-cli < 0.2.3 ember install:addon ember-moment
  • ember-cli >= 0.2.3 ember install ember-moment
{{moment date}}
{{ago date}}
{{duration ms}}

Advance

{{moment date outputFormat inputFormat}}
{{ago date inputFormat}}
{{duration number units}}

Recomputes the time ago every 1-second. This is useful for "live" updating as time elapses.

NOTE: This feature is only supported in Ember >= 1.13.0

{{ago date interval=1000}}

ES6 Moment

This addon provides the ability to import moment as an ES6 module.

import moment from 'moment';

Computed Macro

import computedDuration from 'ember-moment/computeds/duration';
import computedMoment from 'ember-moment/computeds/moment';
import computedAgo from 'ember-moment/computeds/ago';

export default Ember.Controller.extend({
  date: new Date('2013-02-08T09:30:26'),

  // Takes on the behavior of moment().format()
  // http://momentjs.com/docs/#/displaying/format/
  shortDate: computedMoment('date', 'MM/DD/YYYY'),

  // second parameter is what is passed on to the `fromNow` function
  // in this case, `true` is used to display "ago"
  // http://momentjs.com/docs/#/displaying/fromnow/
  timeSince: computedAgo('date', true),

  // duration units: seconds, minutes, hours, days, weeks, months, years
  // http://momentjs.com/docs/#/durations/
  computedNumHours: computedDuration(10, 'hours')
});

Include Moment Timezone

You can optionally include the Moment Timezone package in your config/environment.js like so:

// config.environment.js
module.exports = function(/* environment */) {
  return {
    moment: {
      // Options:
      // 'all' - all years, all timezones
      // '2010-2020' - 2010-2020, all timezones
      // 'none' - no data, just timezone API
      includeTimezone: 'all'
    }
  }
};

Include moment locales for i18n support

// config.environment.js
module.exports = function(environment) {
  return {
    moment: {
      // To cherry-pick specific locale support into your application.
      // Full list of locales: https://github.com/moment/moment/tree/2.10.3/locale
      includeLocales: ['es', 'fr-ca']
    }
  };
// app/routes/applicaton.js
import moment from 'moment';

export default Ember.Route.extend({
  beforeModel() {
    // sets the application locale to Spanish
    moment.locale('es');
  }
});

Feature set of i18n support within moment can be found here: http://momentjs.com/docs/#/i18n/

Development

Running Tests

  • ember test
  • ember test --server

Building

  • ember build

For more information on using ember-cli, visit http://www.ember-cli.com/.

Keywords

FAQs

Package last updated on 23 Jul 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc