-
Notifications
You must be signed in to change notification settings - Fork 154
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
amDuration with moment object #181
Comments
You are probably passing it a string "4" instead of numeric 4. That was my problem. |
If you are passing |
Same issue. My model contains a Duration instance. amDuration pipe does not work. duration = moment.duration('P3M4D');
display 'a few seconds', and it is not the good locale. We can not display instance of moment.Duration with amDuration ? amDuration seems to be more a parser than a formatter. |
Solution may be to accept no argument like this: transform(value: any, ...args: string[]): string {
if (typeof args === 'undefined' || args.length !== 1) {
// throw new Error('DurationPipe: missing required time unit argument');
return moment.duration(value).humanize();
}
return moment.duration(value, args[0] as moment.unitOfTime.DurationConstructor).humanize();
} But it not solve amLocale problem. It seems to accept only date, but duration.locale('fr') is possible. |
Description of the Issue and Steps to Reproduce:
Did you search for duplicate issue? [Yes / No]
YES
Please describe the issue and steps to reproduce, preferably with a code sample / plunker:
I tried piping a moment object with amDuration: 'seconds' based on the illustrations, I expect the string display to say '4 minutes' when the object is 4 minutes ahead of time.
I keep receiving 'a few seconds'
Ensure your issue is isolated to angular2-moment. Issues involving third party tools will be closed unless submitted by the tool's author/maintainer.
Environment:
Webstorm in Windows 10; angular2-moment 1.7.0
Please answer the following questions:
moment
version? 2.18.1moment-timezone
? 0.5.13The text was updated successfully, but these errors were encountered: