Humanizr / Humanizer

Humanizer meets all your .NET needs for manipulating and displaying strings, enums, dates, times, timespans, numbers and quantities

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Humanizing a DateTime using calendar app format

lonix1 opened this issue · comments

From a question on SO without resolution:

I need to humanise an historical DateTime to a string that one typically sees in calendar apps, e.g.:

  • 13:40
  • 00:19
  • yesterday
  • Wed
  • Mon
  • last week
  • two weeks ago
  • four weeks ago
  • last month
  • two months ago
  • July
  • February
  • last year
  • 2020
  • 2019
  • etc...

Can Humanizer do this?

(If I must write new code, are there bits in the library which could help me so I don't need to start from scratch?)

Note the library doesn't give all these formats "out of the box". For example, it may give "16 days ago" whereas I want "2 weeks ago", and it may give "3 days ago" whereas I want "Tue". By default, it does not output all of the above formats, so I'd like to know whether I can configure it to do so?