RelativeTimeFormat.h 821 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. * Copyright (c) 2022, Tim Flynn <trflynn89@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/Optional.h>
  8. #include <AK/StringView.h>
  9. #include <AK/Vector.h>
  10. #include <LibUnicode/Forward.h>
  11. #include <LibUnicode/Locale.h>
  12. namespace Unicode {
  13. // These are just the subset of fields in the CLDR required for ECMA-402.
  14. enum class TimeUnit {
  15. Second,
  16. Minute,
  17. Hour,
  18. Day,
  19. Week,
  20. Month,
  21. Quarter,
  22. Year,
  23. };
  24. struct RelativeTimeFormat {
  25. PluralCategory plurality;
  26. StringView pattern;
  27. };
  28. Optional<TimeUnit> time_unit_from_string(StringView time_unit);
  29. StringView time_unit_to_string(TimeUnit time_unit);
  30. Vector<RelativeTimeFormat> get_relative_time_format_patterns(StringView locale, TimeUnit time_unit, StringView tense_or_number, Style style);
  31. }