These are chat archives for Humanizr/Humanizer

2nd
Feb 2018
Joachim Brehmer
@J-F-B-M
Feb 02 12:21

Hi, how would I change the outputted GrammaticalCase of a TimeSpan.Humanize()?
In german, 1.Weeks().Humanize() => "Eine Woche", but I'd prefer "einer Woche" (especially mind the extra r)

I want to write "in one week"/"in einer Woche", but at the current stage "in "+1.Weeks().Humanize() doesn't work, and any GrammaticalCase-Methods are for DateTime, not TimeSpan.
For now I handle this special case in-situ, as any higher number of weeks is a number, but this will break as soon as want to include more languages than English and German.

Obviously, in the actual case I use a computed TimeSpan which can have any length, but the Tests only break on 1.Weeks()
Martin Strecker
@MaStr11
Feb 02 12:58
@J-F-B-M German grammar for a timespan is incredible hard to get right (you have to take Nominativ, Genitiv, Dativ and Akkusativ into account: ein Tag, im Verlauf eines Tages, in einem Tag, im ersten Tag der Woche). I think it is reasonable to open an issue for this.
Joachim Brehmer
@J-F-B-M
Feb 02 14:02
Okay, thank you.
Joachim Brehmer
@J-F-B-M
Feb 02 14:49

While we are at it, (1) can I communicate to Humanizer that I want the number small (eine Woche instead of Eine Woche) and (2) can I specify a TimeUnit that is rounded up to (1.Minute().Humanize(atLeast: TimeUnit.Day) => "One day")?

For the former I transform it manually to a lowercase-number.
For the later I currently use new TimeSpan(Math.Max(myTimeSpan.Ticks, 1.Days().Ticks)).Humanize(), which is a bit unwieldy in the long run.

Martin Strecker
@MaStr11
Feb 02 14:54
Joachim Brehmer
@J-F-B-M
Feb 02 15:14

As the test shows TimeSpan.FromMilliseconds(10).Humanize(minUnit: <Anything higher than ms>) returns no time. But there is some time in the TimeSpan, that I want to round to the nearest day (in my case). minUnit doesn't achieve that. The only way so far seems to do the rounding manually beforehand.

I see the thought behind minUnit->no time, but I would like to know if an atLeast- or roundUpTo- construct is on-topic for this project or if I'm better off doing it all by myself.

Martin Strecker
@MaStr11
Feb 02 15:32
There isn't an issue for this request, so you may open one. The closest I could find is this #648.