@arsedizioni/ars-utils 21.2.110 → 21.2.112

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -823,6 +823,27 @@ class SystemUtils {
823
823
  }
824
824
  }
825
825
  }
826
+ /**
827
+ * Format number
828
+ * @param value : the number to format
829
+ * @param decimals : the number of decimal places
830
+ * @param locale : the locale to use for formatting
831
+ * @returns : the formatted number as a string
832
+ */
833
+ static formatNumber(value, decimals = 2, locale = 'it-IT') {
834
+ return Intl.NumberFormat(locale, { style: 'decimal', minimumFractionDigits: decimals, maximumFractionDigits: decimals }).format(value ?? 0);
835
+ }
836
+ /**
837
+ * Format currency
838
+ * @param value : the number to format
839
+ * @param currency : the currency code (e.g., 'EUR', 'USD')
840
+ * @param decimals : the number of decimal places
841
+ * @param locale : the locale to use for formatting
842
+ * @returns : the formatted currency as a string
843
+ */
844
+ static formatCurrency(value, currency = 'EUR', decimals = 2, locale = 'it-IT') {
845
+ return Intl.NumberFormat(locale, { style: 'currency', currency: currency, minimumFractionDigits: decimals, maximumFractionDigits: decimals }).format(value ?? 0);
846
+ }
826
847
  /**
827
848
  * Encode url
828
849
  * @param value : the value to encode