Skip to content
Discussion options

You must be logged in to vote

Hello!

Currently, Humanizer is designed for natural language prose (e.g., '2 minutes, 400 milliseconds') rather than technical abbreviations. There isn't a built-in parameter for 'ms'.

However, a clean way to handle this in your project is to create a small extension method that maps the full units to their abbreviations. This keeps the 'humanized' logic while giving you the short format you need:

using Humanizer;
using System.Text.RegularExpressions;

public static class HumanizerExtensions
{
    private static readonly Dictionary<string, string> Abbreviations = new()
    {
        { "millisecond", "ms" },
        { "second", "s" },
        { "minute", "min" },
        { "hour", "h" },

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Drammy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants