Add I18n date format example (#14973)

This commit is contained in:
Michael Kohl 2021-10-09 02:08:56 +07:00 committed by GitHub
parent b898bd3882
commit e3abee660a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 13 deletions

View file

@ -1,9 +1,10 @@
module DateHelper
def local_date(datetime, show_year: true)
datetime = Time.zone.parse(datetime) if datetime.is_a?(String)
format = show_year ? :short_with_year : :short
tag.time(
datetime.strftime("%b %-e#{', %Y' if show_year}"),
l(datetime, format: format),
datetime: datetime.utc.iso8601,
class: "date#{'-no-year' unless show_year}",
)

View file

@ -112,3 +112,7 @@ en:
billing: "Billing"
organization: "Organization"
extensions: "Extensions"
time:
formats:
short: "%b %-e"
short_with_year: "%b %-e, %Y"

View file

@ -67,18 +67,18 @@ fr:
date:
abbr_month_names:
-
- Janv
- Fevr
- Mars
- Avril
- Mai
- Juin
- Juil
- Aout
- Sept
- Oct
- Nov
- Dec
- janv
- vr
- mars
- avril
- mai
- juin
- juil
- aout
- sept
- oct
- nov
- c
errors:
messages:
accepted: doit être accepté
@ -135,3 +135,7 @@ fr:
billing: Facturation
organization: Organisation
extensions: Extensions
time:
formats:
short: "%-e %b"
short_with_year: "%-e %b, %Y"