locale.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. #pragma once
  2. #include <stdbool.h>
  3. #include <furi.h>
  4. #include <furi_hal.h>
  5. #ifdef __cplusplus
  6. extern "C" {
  7. #endif
  8. typedef enum {
  9. LocaleMeasurementUnitsMetric = 0, /**< Metric measurement units */
  10. LocaleMeasurementUnitsImperial = 1, /**< Imperial measurement units */
  11. } LocaleMeasurementUnits;
  12. typedef enum {
  13. LocaleTimeFormat24h = 0, /**< 24-hour format */
  14. LocaleTimeFormat12h = 1, /**< 12-hour format */
  15. } LocaleTimeFormat;
  16. typedef enum {
  17. LocaleDateFormatDMY = 0, /**< Day/Month/Year */
  18. LocaleDateFormatMDY = 1, /**< Month/Day/Year */
  19. LocaleDateFormatYMD = 2, /**< Year/Month/Day */
  20. } LocaleDateFormat;
  21. /** Get Locale measurement units
  22. *
  23. * @return The locale measurement units.
  24. */
  25. LocaleMeasurementUnits locale_get_measurement_unit();
  26. /** Set locale measurement units
  27. *
  28. * @param[in] format The locale measurements units
  29. */
  30. void locale_set_measurement_unit(LocaleMeasurementUnits format);
  31. /** Convert Fahrenheit to Celsius
  32. *
  33. * @param[in] temp_f The Temperature in Fahrenheit
  34. *
  35. * @return The Temperature in Celsius
  36. */
  37. float locale_fahrenheit_to_celsius(float temp_f);
  38. /** Convert Celsius to Fahrenheit
  39. *
  40. * @param[in] temp_c The Temperature in Celsius
  41. *
  42. * @return The Temperature in Fahrenheit
  43. */
  44. float locale_celsius_to_fahrenheit(float temp_c);
  45. /** Get Locale time format
  46. *
  47. * @return The locale time format.
  48. */
  49. LocaleTimeFormat locale_get_time_format();
  50. /** Set Locale Time Format
  51. *
  52. * @param[in] format The Locale Time Format
  53. */
  54. void locale_set_time_format(LocaleTimeFormat format);
  55. /** Format time to furi string
  56. *
  57. * @param[out] out_str The FuriString to store formatted time
  58. * @param[in] datetime Pointer to the datetime
  59. * @param[in] format The Locale Time Format
  60. * @param[in] show_seconds The show seconds flag
  61. */
  62. void locale_format_time(
  63. FuriString* out_str,
  64. const FuriHalRtcDateTime* datetime,
  65. const LocaleTimeFormat format,
  66. const bool show_seconds);
  67. /** Get Locale DateFormat
  68. *
  69. * @return The Locale DateFormat.
  70. */
  71. LocaleDateFormat locale_get_date_format(void);
  72. /** Set Locale DateFormat
  73. *
  74. * @param[in] format The Locale DateFormat
  75. */
  76. void locale_set_date_format(LocaleDateFormat format);
  77. /** Format date to furi string
  78. *
  79. * @param[out] out_str The FuriString to store formatted date
  80. * @param[in] datetime Pointer to the datetime
  81. * @param[in] format The format
  82. * @param[in] separator The separator
  83. */
  84. void locale_format_date(
  85. FuriString* out_str,
  86. const FuriHalRtcDateTime* datetime,
  87. const LocaleDateFormat format,
  88. const char* separator);
  89. #ifdef __cplusplus
  90. }
  91. #endif