Humanize Your C# Code with the Humanizer NuGet Package

preview_player
Показать описание
Converting values in code can be tricky. For example, if you rank something, you would say that the top pick is in first place, not in 1 place. Those types of conversions are simple for humans to do but tricky for software to do. Fortunately, the Humanizer package makes these types of conversions easy. From converting 4:30pm to half past four to knowing how to transform a string to be a specific enum value, this package seemingly does it all.

Рекомендации по теме
Комментарии
Автор

Nice Tim, didn't feel it very useful at first but glad I stayed until the end. I can definitely use the DateTime conversion in one of my apps.

marcoguerra
Автор

Pretty cool, the heading thing could be useful for a weather app. This is pretty cool. Not sure I have an immediate use case currently but I will keep it in mind in the future. Thanks for showing it.

newmonengineering
Автор

BEWARE, for me, turning on the beta UTF-8 option, Control Panel -> Region -> Administrative tab -> Change system locale -> "Beta: Use unicode UTF-8 for worldwide language support", resulted in Outlook sending really strange emails on my end. For me, it was emails that contained quoted text, when accepting or declining a calendar invite based on an MS-Teams meeting. Very strange, but ultimately had to turn off this feature, due to the problem. My team and I were able to reproduce it and trace the problem back to enabling that feature in Regional settings, from my most recent watch of another excellent Tim Corey video!

codefoxtrot
Автор

Thats cool. Thanks for bringing this up. I would like to see if it can dehumanize "previous Saturday" to date value.

Keen
Автор

I used substring, for the truncate, and I had to create a class library to do the ' humanize' time.


This is a great solution!

rikudouensof
Автор

This package will be really helpful on my timeline screen that shows you, well a timeline.

Although I am a bit freaked out by your pronunciation of enum 😂

MiningForPies
Автор

Happy Nowruz Tim.📣📣📣🤗
Wish you a great and amazing year full of wealth and opportunities and wishes to come true, not this year but for a lifetime😍😊

EliasLoveL
Автор

This looks like it could be a useful library.
Usually, I'd write these kinds of converters myself, to get exactly the output I expect, but this could be a shorthand, especially for the enum converters. However, for me, there's a few (small) issues:

- Sentence case isn't really creating sentence case. The 2nd sentence didn't start with a capital letter.
- Title case wasn't title case. It was just changing the 1st letter of each word to a capital. It should ignore conjunctions and smaller words in the middle of the sentence.
- Time. For the UK, we don't say, "a quarter to five". We'd say, "quarter to five". Is there a UK language version? There might be. Otherwise, I'd have to add my own extension to fix this.
- For consistency with the other methods, to convert the sizes, I'd expect .Megabytes & .Terabytes to be: .ToMegabytes & .ToTerabytes or even: .AsMegabytes & .AsTerabytes

DarrenTAnims
Автор

Wow, this package is amazing. Thanx for introducing it to us 🙂

CoderboyPB
Автор

Thanks.

I agree the Dehumanize name is unfortunate. I would have Robotize or Computerize.

dereklomax
Автор

@25:06 - the "and" is a British thing - I'd always say "one hundred and twenty two", not "one hundred twenty two" as my US colleagues would. I'd imagine the authors speak British English.

davedontmind
Автор

Wow you can do some really cool stuff with that might some good ideas where to use it in my app 🙂. As always great video. Thank's for sharing.

pawelpawel
Автор

While its very interesting and very useful to me... its ironically sad cos i just created code library that does most of these... wish i saw this few months ago; would have saved a tone of time. Thank you very much... still totally usefull.

ogheneroonoruvwe
Автор

I haven't tried the language-specific version yet, but the core seems to have some issues if system language is not set to English. I'm using Windows in Polish and when I try to humanize DateTime.Now.AddHours(3.5) I get an exception: System.ArgumentException: „The resource object with key was not found Arg_ParamName_Name”. Also, ToClockNotation returns "a quarter to cztery" (cztery is four in Polish, but in context of time it should be czwarta - fourth, so it's a little far from correct). It's a shame that the environment in which it runs can so easily break it.

Zjyslav
Автор

Words cannot begin describe how much I detest relative timestamps.

billybob
Автор

Its a lot of fun, but not always deterministic, a lot lot like natural language.

dianajdanj
Автор

I'm glad to say that I contributed for Tamil language.

HouseWashing
Автор

But we really need a third party library for this? Can't you just create a function for that particular 'pretty' result?

senaris
Автор

linux user a gigabyte is a gigabyte a 1000 is a 1000
thank you for all the tutorials

AhmedMohammed
Автор

Rather than - doesn't do the same thing?

rockymarquiss