Skip to content

Add option to customize list of time indicators of humanized timespans #497

Closed
@tiesmaster

Description

@tiesmaster

Probably this title needs some explanation ;) When you humanize a timespan, like this:

        const int ONE_WEEK_ONE_DAY = 8;
        var oneWeekOneDayTimeSpan = TimeSpan.FromDays(ONE_WEEK_ONE_DAY);
        var result = oneWeekOneDayTimeSpan.Humanize(2);

then you get "1 week, 1 day". However, what I want is to have the option to override the concatenation of the strings, to have an ", and", instead of only a comma between the second to last, and last item, making the output this:

1 week, and 1 day

AFAICT, you cannot do this now with Humanizer, and couldn't find an issue for this. I'd suggest adding a separator argument to the call, similar to how you can specify that on the Humanize call for collections. However, I'm not sure if you want another overload for this, besides the other two.

I'm happy to make a PR, if my proposal is accepted, and we can find a good way to add it to the API.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions