static string Humanize( System.DateTime dateTime )
static string Humanize( System.DateTimeOffset dateTime )
static string Humanize( System.TimeOnly dateTime )
static string Humanize( System.DateOnly dateTime )
static string Humanize( System.TimeSpan dateTime, int precision )
static string Humanize( System.TimeSpan timespan, bool shortVersion, bool minutes, bool hours, bool days )

robot_2Generated
code_blocksInput

Description

The Humanize method is a static extension method provided by the SandboxSystemExtensions class. It is used to convert a DateTime object into a human-readable string format. This method is particularly useful for displaying dates and times in a format that is easily understandable by end-users, such as "2 days ago" or "in 3 hours".

Usage

To use the Humanize method, you need to have a DateTime object that you want to convert into a human-readable string. This method is an extension method, so it can be called directly on any DateTime instance.

Example usage:

DateTime myDateTime = DateTime.Now.AddHours(-5);
string humanReadable = myDateTime.Humanize();
// Output might be "5 hours ago"

Example

DateTime myDateTime = DateTime.Now.AddDays(-2);
string humanReadable = myDateTime.Humanize();
// Output: "2 days ago"