Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-64977

Add functionality to moodlelib to have integer/float output with thousands separator

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 3.7
    • Fix Version/s: None
    • Component/s: General, Language
    • Labels:
      None
    • Affected Branches:
      MOODLE_37_STABLE

      Description

      External plugins (and also Moodle core) could profit from core functionality that outputs an integer number (or a floating-point number) with thousands separator.

      Function format_float in lib/moodlelib.php allows for output of a floating-point value with a decimal separator. It never includes a separator between groups of thousands. The function can also be used to output integer numbers. And it allows for localised output.

      I would like to suggest a change to format_float that adds a boolean parameter (like $usethousandsseparator) with a default value of false. If the value is false, the function behaves as it does now. If the parameter is true, a ',' (comma) is inserted between groups of thousands if $localized is false, and the value of string thousandssep is used instead to group thousands if $localized is true.

      Possible edge cases to consider:

      • decsep and thousandssep are the same value,
      • one or both of decsep and thousandssep are empty,
      • one or both of decsep and thousandssep are longer than one character (or byte),
      • combinations of these cases.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              nicoroeser Nico Roeser
              Participants:
              Component watchers:
              Jake Dallimore, Jun Pataleta, Ryan Wyllie, cameron1729, David Mudrák (@mudrd8mz), Helen Foster
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: