chunk.DQ4C4KGR.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. import {
  2. e,
  3. h,
  4. n
  5. } from "./chunk.5PIDMFOE.js";
  6. import {
  7. __decorateClass
  8. } from "./chunk.IHGPZX35.js";
  9. // src/components/format-date/format-date.ts
  10. var SlFormatDate = class extends h {
  11. constructor() {
  12. super(...arguments);
  13. this.date = new Date();
  14. this.hourFormat = "auto";
  15. }
  16. render() {
  17. const date = new Date(this.date);
  18. const hour12 = this.hourFormat === "auto" ? void 0 : this.hourFormat === "12";
  19. if (isNaN(date.getMilliseconds())) {
  20. return;
  21. }
  22. return new Intl.DateTimeFormat(this.locale, {
  23. weekday: this.weekday,
  24. era: this.era,
  25. year: this.year,
  26. month: this.month,
  27. day: this.day,
  28. hour: this.hour,
  29. minute: this.minute,
  30. second: this.second,
  31. timeZoneName: this.timeZoneName,
  32. timeZone: this.timeZone,
  33. hour12
  34. }).format(date);
  35. }
  36. };
  37. __decorateClass([
  38. e()
  39. ], SlFormatDate.prototype, "date", 2);
  40. __decorateClass([
  41. e()
  42. ], SlFormatDate.prototype, "locale", 2);
  43. __decorateClass([
  44. e()
  45. ], SlFormatDate.prototype, "weekday", 2);
  46. __decorateClass([
  47. e()
  48. ], SlFormatDate.prototype, "era", 2);
  49. __decorateClass([
  50. e()
  51. ], SlFormatDate.prototype, "year", 2);
  52. __decorateClass([
  53. e()
  54. ], SlFormatDate.prototype, "month", 2);
  55. __decorateClass([
  56. e()
  57. ], SlFormatDate.prototype, "day", 2);
  58. __decorateClass([
  59. e()
  60. ], SlFormatDate.prototype, "hour", 2);
  61. __decorateClass([
  62. e()
  63. ], SlFormatDate.prototype, "minute", 2);
  64. __decorateClass([
  65. e()
  66. ], SlFormatDate.prototype, "second", 2);
  67. __decorateClass([
  68. e({ attribute: "time-zone-name" })
  69. ], SlFormatDate.prototype, "timeZoneName", 2);
  70. __decorateClass([
  71. e({ attribute: "time-zone" })
  72. ], SlFormatDate.prototype, "timeZone", 2);
  73. __decorateClass([
  74. e({ attribute: "hour-format" })
  75. ], SlFormatDate.prototype, "hourFormat", 2);
  76. SlFormatDate = __decorateClass([
  77. n("sl-format-date")
  78. ], SlFormatDate);
  79. var format_date_default = SlFormatDate;
  80. export {
  81. format_date_default
  82. };