urish / ngx-moment

moment.js pipes for Angular
MIT License
1.17k stars 154 forks source link

Setting relativeTimeThresholdOptions object doesn't work #231

Open Cthulahoop opened 4 years ago

Cthulahoop commented 4 years ago

Description of the Issue and Steps to Reproduce:

Did you search for duplicate issue? [Yes / ~no~]

Please describe the issue and steps to reproduce, preferably with a code sample / plunker:

Adding the relativeTimeThresholdOptions object to the imports as shown in the Usage section of the readme doesn't change the moment relative time thresholds.

Demo

Please see StackBlitz demo here

Notes

The workaround is to set moment.relativeTimeThreshold manually, but this is kludgy.

Ensure your issue is isolated to ngx-moment. Issues involving third party tools will be closed unless submitted by the tool's author/maintainer.

Environment:

Please answer the following questions:

StickNitro commented 4 years ago

The relativeTimeThresholdOptions do not actually get set on the moment object, they are set and used (currently) in the amDuration pipe, so they will not get set on the moment object until the amDuration pipe gets called.

If you add a call in your template to the amDuration pipe then you will see that moment.relativeTimeThreshold('ss') will return the correct value

darron1217 commented 4 years ago

That's weird. relativeTimeThresholdOptions should also be applied to amTimeAgo pipe.

libinvarghese commented 3 years ago

When using moment.from or moment.fromNow moment uses the Relative Time Thresholds

See example