/udes-moment

UdeS moment element wrapper for Moment.js

Primary LanguageHTMLMIT LicenseMIT

<udes-moment>

Published on webcomponents.org

udes-moment is a Polymer 2 wrapper for the Moment.js library.

There are currently 2 components and 1 mixin available:

  • Components
    • <udes-moment>
    • <udes-moment-interval>
  • Mixin
    • UdeS.MomentMixin

The UdeS.MomentImportMixin is not intented to be use outside this repositery.

All the components and mixins use the UdeS.LanguageMixin to automatically update the date according to the global language.

What should I use?

You should use the UdeS.MomentMixin if you have many dates to format inside you component. If you have only one or two, use the components instead.

Configuration

If you use one of the components or one of the mixins, you need to update your polymer.json to includes the Moment.js files:

{
  "extraDependencies": [
    "bower_components/moment/min/moment.min.js",
    "bower_components/moment/locale/*.js"
  ],
}

You also need to update your sw-precache-config.js accordingly:

/* eslint-disable-next-line no-undef */
module.exports = {
  staticFileGlobs: [
    'bower_components/moment/locale/*',
    'bower_components/moment/min/moment.min.js',
  ],
};

Demo

<udes-moment-demo></udes-moment>