Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
Dan Croak authored October 12, 2012
2  README.md
Source Rendered
@@ -52,7 +52,7 @@ Suspenders also comes with:
52 52
 
53 53
 * Override recipient emails in staging environment.
54 54
 * Rails' flashes set up and in application layout.
55  
-* A few nice time formats.
  55
+* A few nice time formats set up for localization.
56 56
 * [Heroku-recommended asset pipeline
57 57
   settings](https://devcenter.heroku.com/articles/rails3x-asset-pipeline-cedar/).
58 58
 
6  lib/suspenders/app_builder.rb
@@ -109,6 +109,11 @@ def configure_time_zone
109 109
       inject_into_class "config/application.rb", "Application", time_zone_config
110 110
     end
111 111
 
  112
+    def configure_time_formats
  113
+      remove_file 'config/locales/en.yml'
  114
+      copy_file 'config_locales_en.yml', 'config/locales/en.yml'
  115
+    end
  116
+
112 117
     def configure_action_mailer
113 118
       action_mailer_host 'development', "#{app_name}.local"
114 119
       action_mailer_host 'test', 'www.example.com'
@@ -184,7 +189,6 @@ def create_github_repo(repo_name)
184 189
 
185 190
     def copy_miscellaneous_files
186 191
       copy_file 'errors.rb', 'config/initializers/errors.rb'
187  
-      copy_file 'time_formats.rb', 'config/initializers/time_formats.rb'
188 192
       copy_file 'Procfile'
189 193
     end
190 194
 
1  lib/suspenders/generators/app_generator.rb
@@ -112,6 +112,7 @@ def configure_app
112 112
       build :configure_action_mailer
113 113
       build :generate_rspec
114 114
       build :configure_time_zone
  115
+      build :configure_time_formats
115 116
 
116 117
       if options[:webkit]
117 118
         build :configure_capybara_webkit
11  templates/config_locales_en.yml
... ...
@@ -0,0 +1,11 @@
  1
+en:
  2
+  date:
  3
+    formats:
  4
+      default: '%m/%d/%Y'
  5
+      with_weekday: '%a %m/%d/%y'
  6
+
  7
+  time:
  8
+    formats:
  9
+      default: '%a, %b %-d, %Y at %r'
  10
+      date: '%b %-d, %Y'
  11
+      short: '%B %d'
6  templates/time_formats.rb
... ...
@@ -1,6 +0,0 @@
1  
-# {
2  
-#  :short_date  => "%x",              # 04/13/10
3  
-#  :long_date   => "%a, %b %d, %Y"    # Tue, Apr 13, 2010
4  
-# }.each do |format_name, format_string|
5  
-#   Time::DATE_FORMATS[format_name] = format_string
6  
-# end

0 notes on commit fbf3fcd

Please sign in to comment.
Something went wrong with that request. Please try again.