There was one missing functionality in the Date Plugin, which is an ability to get relative times which you can do by passing the parameters into the function in the Moment.js library. But it looks like you can’t do that in the plugin itself, which is simply a part of writing mistake in the plugin’s source.

I see in the source you can actually pass some arguments into the plugin, and it should iterate those arguments into the moment() function instead like this:

  if(!window._alreadyLoadedDatePluginCode8934792) {
    loadPluginCode();
    window._alreadyLoadedDatePluginCode8934792 = true;
  }
  return moment(...args);

So now, getting relative times directly from the date plugin should work, just like what you would in the original Moment.js library. And there should also be a documentation somewhere in the plugin page.

  • VioneT@lemmy.worldM
    link
    fedilink
    English
    arrow-up
    2
    ·
    8 months ago

    And there should also be a documentation somewhere in the plugin page.

    There is a link to the Moment.js website on the notes.

    But yeah, relative dates via date('20121212', 'YYYYMMDD') doesn’t work with the current one.