Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Configure time formats

Replace old, commented out time initializer with locale:

http://robots.thoughtbot.com/post/21920979385
  • Loading branch information...
commit fbf3fcdbaf51bfc64154067da3b97ae7669283d8 1 parent 4b7e40a
@croaky croaky authored
View
2  README.md
@@ -52,7 +52,7 @@ Suspenders also comes with:
* Override recipient emails in staging environment.
* Rails' flashes set up and in application layout.
-* A few nice time formats.
+* A few nice time formats set up for localization.
* [Heroku-recommended asset pipeline
settings](https://devcenter.heroku.com/articles/rails3x-asset-pipeline-cedar/).
View
6 lib/suspenders/app_builder.rb
@@ -109,6 +109,11 @@ def configure_time_zone
inject_into_class "config/application.rb", "Application", time_zone_config
end
+ def configure_time_formats
+ remove_file 'config/locales/en.yml'
+ copy_file 'config_locales_en.yml', 'config/locales/en.yml'
+ end
+
def configure_action_mailer
action_mailer_host 'development', "#{app_name}.local"
action_mailer_host 'test', 'www.example.com'
@@ -184,7 +189,6 @@ def create_github_repo(repo_name)
def copy_miscellaneous_files
copy_file 'errors.rb', 'config/initializers/errors.rb'
- copy_file 'time_formats.rb', 'config/initializers/time_formats.rb'
copy_file 'Procfile'
end
View
1  lib/suspenders/generators/app_generator.rb
@@ -112,6 +112,7 @@ def configure_app
build :configure_action_mailer
build :generate_rspec
build :configure_time_zone
+ build :configure_time_formats
if options[:webkit]
build :configure_capybara_webkit
View
11 templates/config_locales_en.yml
@@ -0,0 +1,11 @@
+en:
+ date:
+ formats:
+ default: '%m/%d/%Y'
+ with_weekday: '%a %m/%d/%y'
+
+ time:
+ formats:
+ default: '%a, %b %-d, %Y at %r'
+ date: '%b %-d, %Y'
+ short: '%B %d'
View
6 templates/time_formats.rb
@@ -1,6 +0,0 @@
-# {
-# :short_date => "%x", # 04/13/10
-# :long_date => "%a, %b %d, %Y" # Tue, Apr 13, 2010
-# }.each do |format_name, format_string|
-# Time::DATE_FORMATS[format_name] = format_string
-# end
Please sign in to comment.
Something went wrong with that request. Please try again.