How to convert ISO duration and humanize it

684 Views Asked by At

I have an ISO value of duration, that I need show like "XX years, XX months, XX days". I use for it luxon and humanize-duration. Duration.fromISO() works fine, but humanize-duration converting went wrong. Could you help please?

transform(value: string): string {
    console.log(value);
    let formattedIso = Duration.fromISO(value);
    console.log(humanizeDuration(formattedIso, { language: 'en', units: ["y", "mo", "d"], round: true}));
}

OUTPUT:

P1Y11M3D; 1 year, 10 months, 28 days

P2Y1M30D; 2 years, 1 month, 29 days

0

There are 0 best solutions below