Skip to content
FutureBlitz

    Install

    Import std.text.humanize

    Humanize

    std.text.humanize

    class

    Public Class Humanize

    Humanize's operations.

    Examples

    Expect(Humanize.Plural(3, "box") == "3 boxes")
    Expect(Humanize.Ordinal(22) == "22nd")
    Expect(Humanize.Words(42) == "forty-two")
    Expect(Humanize.SnakeCase("HttpServerName") == "http_server_name")
    Expect(Humanize.Relative(-180) == "3 minutes ago")

    std/text/humanize.fb, line 28

    • Public Static Method Plural(word: String): String static method #

      word's plural: "city" is "cities", "box" "boxes", "leaf" "leaves", "person" "people", and "sheep" "sheep". Of several words, the last one's. A word keeps its capitals, as "TreeNode" does in "TreeNodes", and one in capitals has its ending in them too.

    • Public Static Method Plural(count: Int64, word: String): String static method #

      count and word, the word in its plural unless count is 1 or -1: "3 files", "1 file", and "0 files".

    • Public Static Method Relative(seconds: Int64): String static method #

      How long ago a time seconds from now was, when seconds is negative, "3 minutes ago", or how far off it is, "in 3 minutes", rounded to the unit people would say: "just now" under 45 seconds either way, then a minute, minutes, an hour, hours, a day, days, a month, months, a year, and years.

    • Public Static Method Relative(d: Duration): String static method #

      How long ago a time d before now was, when d is before 0, or how far off one d from now is, as Relative says it of d's whole seconds: "3 minutes ago" and "in 2 hours".

    • Public Static Method Ordinal(n: Int64): String static method #

      n with its ordinal's ending: "1st", "2nd", "3rd", "4th", "11th", "22nd", and "113th".

    • Public Static Method Words(n: Int64): String static method #

      n in words: "zero", "forty-two", "one thousand two hundred thirty-four", and "minus seven".

    • Public Static Method SnakeCase(text: String): String static method #

      text's words in snake_case: "Hello World", "helloWorld", and "HTTPServer2" are "hello_world", "hello_world", and "http_server2". Words are split at spaces, punctuation, and capitals that start one, and a run of capitals is one word.

    • Public Static Method KebabCase(text: String): String static method #

      text's words in kebab-case: "hello-world".

    • Public Static Method CamelCase(text: String): String static method #

      text's words in camelCase: "helloWorld", "httpServer2".

    • Public Static Method PascalCase(text: String): String static method #

      text's words in PascalCase: "HelloWorld", "HttpServer2".

    Report an issue with this page or with FutureBlitz on GitHub.