Humanizer.TimeSpanDehumanizeExtensions
TimeSpanDehumanizeExtensions Class
Contains extension methods for parsing invariant duration text into a System.TimeSpan.
public static class TimeSpanDehumanizeExtensions
Inheritance System.Object → TimeSpanDehumanizeExtensions
Methods
TimeSpanDehumanizeExtensions.DehumanizeTimeSpan(this string) Method
Parses a standard invariant System.TimeSpan value or compact duration tokens using
ms, s, m, h, d, and w.
public static System.TimeSpan DehumanizeTimeSpan(this string input);
Parameters
input System.String
The duration text to parse.
Returns
System.TimeSpan
The parsed duration.
Exceptions
System.ArgumentNullException
Thrown when input is null.
System.FormatException
Thrown when input is not a supported duration.
Remarks
Compact tokens are culture-invariant, may be separated by whitespace, and may have one leading sign. Units may repeat and appear in any order; their values are added. Each token must resolve to whole ticks. A week is seven days. Colon-separated values use the standard invariant System.TimeSpan interpretation.
TimeSpanDehumanizeExtensions.TryDehumanizeTimeSpan(this string, TimeSpan) Method
Tries to parse a standard invariant System.TimeSpan value or compact duration tokens using
ms, s, m, h, d, and w.
public static bool TryDehumanizeTimeSpan(this string? input, out System.TimeSpan result);
Parameters
input System.String
The duration text to parse.
result System.TimeSpan
The parsed duration, or System.TimeSpan.Zero when parsing fails.
Returns
System.Boolean
true when parsing succeeds; otherwise, false.
Remarks
Compact tokens are culture-invariant, may be separated by whitespace, and may have one leading sign. Units may repeat and appear in any order; their values are added. Each token must resolve to whole ticks. A week is seven days. Colon-separated values use the standard invariant System.TimeSpan interpretation.