-
-
Save masak2009/a122f88204e79d4ef518847eb22dbd6f to your computer and use it in GitHub Desktop.
Dump date/time formats with examples of a locale in Rails
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ bin/rake i18n:show_sample_dates_and_times['en-MY'] | |
time: | |
date : %m/%d/%Y : 2012-10-15 | |
date_day : %d : 15 | |
date_hour : %l:%M %p : 4:13 pm | |
date_month : %B : October | |
date_month_name : %B %e, %Y : 15 October 2012 | |
date_month_year : %B %Y : October 2012 | |
date_short_month_year : %e %b %Y : 15 Oct 2012 | |
date_short_year : %m/%d/%y : 15-10-12 | |
date_with_hour : %B %e, %Y @ %l:%M%p : 15 October 2012 @ 4:13pm | |
date_with_zone : %B %e %l:%M%p %Z : 15 October 4:13pm CDT | |
day_month : %e %B : 15 October | |
day_short_month : %e %b : 15 Oct | |
default : %a, %d %b %Y %H:%M:%S %z : Mon, 15 Oct 2012 16:13:27 -0500 | |
long : %B %d, %Y %H:%M : 15 October 2012 16:13 | |
short : %d %b %H:%M : 15 Oct 16:13 | |
title_endian : %d %b %Y : 15 Oct 2012 | |
twelve_hour_time : %I %p : 04 pm | |
year : %Y : 2012 | |
date: | |
date : %m/%d/%Y : 2012-10-15 | |
date_day : %d : 15 | |
date_hour : %l:%M %p : 12:00 | |
date_month : %B : October | |
date_month_name : %B %e, %Y : 15 October 2012 | |
date_month_year : %B %Y : October 2012 | |
date_short_month_year : %e %b %Y : 15 Oct 2012 | |
date_short_year : %m/%d/%y : 12-10-15 | |
date_with_hour : %B %e, %Y @ %l:%M%p : 15 October 2012 @ 12:00 | |
day_month_date : %A, %B %e : Monday, 15 October | |
default : %Y-%m-%d : 15-10-2012 | |
long : %B %d, %Y : 15 October 2012 | |
month_day : %m/%d : 10-15 | |
short : %b %d : 15 Oct | |
title_endian : %d %b %Y : 15 Oct 2012 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
desc "Show sample dates and times" | |
task :show_sample_dates_and_times, [:locale] => [:environment] do |t, args| | |
I18n.with_locale args.locale do | |
puts "time:" | |
(I18n.t :"time.formats", :locale => :en).to_a.sort.each do |format_sym, format_string| | |
puts " #{format_sym.to_s.ljust(30)}: #{format_string.ljust(30)}: #{I18n.l(Time.now, :format => format_sym)}" | |
end | |
puts "date:" | |
(I18n.t :"date.formats", :locale => :en).to_a.sort.each do |format_sym, format_string| | |
puts " #{format_sym.to_s.ljust(30)}: #{format_string.ljust(30)}: #{I18n.l(Date.current, :format => format_sym)}" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment