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

ember-cli-moment-shim

Package Overview
Dependencies
Maintainers
2
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ember-cli-moment-shim

Brings moment and moment-timezone into your Ember applications

  • 3.3.3
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

ember-cli-moment-shim

Build Status npm Version Ember Observer Score Ember badge

ES6 accessible module for momentjs within your Ember applications.

Usage

  • ember install ember-cli-moment-shim
import moment from 'moment';

Features

  • ES6 accessible module for moment
  • Convient way to bring in locales & timezones through configuration
  • FastBoot support

Upgrading

Be sure to rerun the default blueprint with ember g ember-cli-moment-shim if upgrading by bumping the version number in package.json.

Enabling moment-timezone

// config.environment.js
module.exports = function(environment) {
  return {
    moment: {
      // Options:
      // 'all' - all years, all timezones
      // 'subset' - subset of the timezone data to cover 2010-2020 (or 2012-2022 as of 0.5.12). all timezones.
      // 'none' - no data, just timezone API
      includeTimezone: 'all'
    }
  };
}

i18n support

Cherry pick locales (optimal)

// 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']
    }
  };

NOTE: English is bundled automatically, not need to add en in includeLocales

Include all locales

// config.environment.js
module.exports = function(environment) {
  return {
    moment: {
      includeLocales: true
    }
  };

Configure default runtime locale

// app/routes/applicaton.js
import moment from 'moment';

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

Write all the locales to a folder relative to dist

// config.environment.js
module.exports = function(environment) {
  return {
    moment: {
      // This will output _all_ locale scripts to assets/moment-locales
      // this option does not respect includeLocales
      localeOutputPath: 'assets/moment-locales'
    }
  };

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

License

ember-cli-moment-shim shims is MIT Licensed.

Keywords

FAQs

Package last updated on 27 Jun 2017

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