Skip to content

Commit dbc19c6

Browse files
authored
Merge pull request #377 from baikiet/master
Format dates in a nicer way.
2 parents 0310a78 + d0aa506 commit dbc19c6

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed

app/helpers/node_helper.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,7 @@ def posted_by(content, user_link='Anonyme')
117117
end
118118
date_time = content.is_a?(Comment) ? content.created_at : content.node.try(:created_at)
119119
date_time ||= Time.now
120-
date = content_tag(:span, "le #{date_time.to_s(:date)}", class: "date")
121-
time = content_tag(:span, "à #{date_time.to_s(:time)}", class: "time")
122-
published_at = content_tag(:time, date + " " + time, datetime: date_time.iso8601, class: "updated")
120+
published_at = content_tag(:time, "le #{date_time.to_s(:posted)}", datetime: date_time.iso8601, class: "updated")
123121
caption = content_tag(:span, "", class: "floating_spacer") +
124122
content_tag(:span, "Posté par #{ user_link } #{ published_at }.".html_safe, class: "posted_by_spanblock")
125123
caption.html_safe

app/views/redaction/index.html.haml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
- if n.nb_editors > 0
4646
= "& #{pluralize n.nb_editors, "participant"}"
4747
%h3= link_to n.title, [:redaction, n]
48-
Modifiée le #{n.updated_at.to_s :date} à #{n.updated_at.to_s :time}
48+
Modifiée le #{n.updated_at.to_s :posted}
4949

5050
%h2 #{pluralize @news.count, "dépêche"} en cours de modération
5151
- feed "Flux Atom des dépêches en cours de modération", "/redaction/news/moderation.atom"

config/initializers/time_formats.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# encoding: UTF-8
22
date_formats = {
3-
date: '%d/%m/%y',
4-
posted: '%d/%m/%y à %H:%M',
3+
posted: ->(t) {I18n.l(t, format: :posted)},
54
norloge: '%H:%M:%S',
65
norloge2: '%Y-%m-%d %H:%M:%S',
76
timestamp: '%Y%m%d%H%M%S'

config/locales/date.fr.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
fr:
2+
time:
3+
formats:
4+
posted: '%d %B %Y à %H:%M'

0 commit comments

Comments
 (0)