diff --git a/app/javascript/controllers/local_time_controller.js b/app/javascript/controllers/local_time_controller.js index 445545a76..86d5e58e6 100644 --- a/app/javascript/controllers/local_time_controller.js +++ b/app/javascript/controllers/local_time_controller.js @@ -1,11 +1,12 @@ import { Controller } from "@hotwired/stimulus" export default class extends Controller { - static targets = ["time", "date", "datetime", "ago"] + static targets = ["time", "date", "datetime", "shortdate", "ago"] initialize() { this.timeFormatter = new Intl.DateTimeFormat(undefined, { timeStyle: "short" }) this.dateFormatter = new Intl.DateTimeFormat(undefined, { dateStyle: "long" }) + this.shortDateFormatter = new Intl.DateTimeFormat(undefined, { month: "short", day: "numeric" }) this.dateTimeFormatter = new Intl.DateTimeFormat(undefined, { timeStyle: "short", dateStyle: "short" }) this.agoFormatter = new AgoFormatter() } @@ -22,6 +23,10 @@ export default class extends Controller { this.#formatTime(this.dateTimeFormatter, target) } + shortdateTargetConnected(target) { + this.#formatTime(this.shortDateFormatter, target) + } + agoTargetConnected(target) { this.#formatTime(this.agoFormatter, target) } diff --git a/app/views/comments/_body.html.erb b/app/views/comments/_body.html.erb index d2a060192..63581c7aa 100644 --- a/app/views/comments/_body.html.erb +++ b/app/views/comments/_body.html.erb @@ -3,9 +3,7 @@
<%= link_to comment.creator.name, user_path(comment.creator), class: "txt-ink btn btn--plain", data: { turbo_frame: "_top" } %> <%= link_to bucket_bubble_path(comment.bubble.bucket, comment.bubble, anchor: "comment_#{comment.id}"), class: "txt-undecorated" do %> - <%= tag.time comment.created_at, class: "comment__timestamp" do %> - <%= comment.created_at.strftime("%b %d") %> - <% end %> + <%= local_datetime_tag comment.created_at, style: :shortdate, class: "comment__timestamp" %> <% end %> <% if comment.creator == Current.user %>