Back to Gems
jasonmit/ember-cli-moment-shim(opens in a new tab)
Language: JavaScript
ember-cli shim for momentjs
- stars
- 33
- watchers
- 2
- forks
- 55
- open issues
- 2
- Last updated
- 03/30/2023
Language: JavaScript
ember-cli shim for momentjs
As of ember-moment v10 this library is no longer required to import moment, moment-timezone, or configure any of the build options. Instuctions for bundling locale and timezone data can be found in the ember-moment readme.
ember-cli ES6 module shim for momentjs and moment timezone within your Ember applications. It will also conditionally bundle in specific locale/timezone data for those concerned about payload size.
ember install ember-cli-moment-shimimport moment from 'moment';
// 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' } }; }
// 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/master/locale includeLocales: ['es', 'fr-ca'] } };
NOTE: English is bundled automatically – no need to add en in includeLocales
// config/environment.js module.exports = function(environment) { return { moment: { includeLocales: true } };
// app/routes/applicaton.js import moment from 'moment'; export default Ember.Route.extend({ beforeModel() { // sets the application locale to Spanish moment.locale('es'); } });
// 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' } };
The feature set for i18n support within moment can be found here: http://momentjs.com/docs/#/i18n/
ember-cli-moment-shim shims is MIT Licensed.