CARVIEW |
Select Language
HTTP/2 302
server: nginx
date: Wed, 20 Aug 2025 07:43:05 GMT
content-type: text/plain; charset=utf-8
content-length: 0
x-archive-redirect-reason: found capture at 20100309143238
location: https://web.archive.org/web/20100309143238/https://github.com/clemens/localized_dates
server-timing: captures_list;dur=0.600709, exclusion.robots;dur=0.021093, exclusion.robots.policy;dur=0.009913, esindex;dur=0.013813, cdx.remote;dur=18.243840, LoadShardBlock;dur=248.838801, PetaboxLoader3.datanode;dur=104.576446, PetaboxLoader3.resolve;dur=97.384844
x-app-server: wwwb-app219
x-ts: 302
x-tr: 301
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=0
set-cookie: wb-p-SERVER=wwwb-app219; path=/
x-location: All
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
HTTP/2 200
server: nginx
date: Wed, 20 Aug 2025 07:43:06 GMT
content-type: text/html; charset=utf-8
x-archive-orig-server: nginx/0.7.61
x-archive-orig-date: Tue, 09 Mar 2010 14:32:38 GMT
x-archive-orig-connection: close
x-archive-orig-status: 200 OK
x-archive-orig-etag: "88660fac86b4806f4332e09b465ee549"
x-archive-orig-x-runtime: 100ms
x-archive-orig-content-length: 29314
x-archive-orig-cache-control: private, max-age=0, must-revalidate
x-archive-guessed-content-type: text/html
x-archive-guessed-charset: maccentraleurope
memento-datetime: Tue, 09 Mar 2010 14:32:38 GMT
link: ; rel="original", ; rel="timemap"; type="application/link-format", ; rel="timegate", ; rel="first memento"; datetime="Tue, 16 Sep 2008 22:35:31 GMT", ; rel="prev memento"; datetime="Sat, 03 Oct 2009 16:51:13 GMT", ; rel="memento"; datetime="Tue, 09 Mar 2010 14:32:38 GMT", ; rel="next memento"; datetime="Tue, 13 Apr 2010 23:15:27 GMT", ; rel="last memento"; datetime="Wed, 09 Sep 2020 22:24:21 GMT"
content-security-policy: default-src 'self' 'unsafe-eval' 'unsafe-inline' data: blob: archive.org web.archive.org web-static.archive.org wayback-api.archive.org athena.archive.org analytics.archive.org pragma.archivelab.org wwwb-events.archive.org
x-archive-src: 51_14_20100309102928_crawl102-c/51_14_20100309143209_crawl101.arc.gz
server-timing: captures_list;dur=0.556512, exclusion.robots;dur=0.021184, exclusion.robots.policy;dur=0.010036, esindex;dur=0.013018, cdx.remote;dur=15.866648, LoadShardBlock;dur=251.352929, PetaboxLoader3.datanode;dur=164.032815, PetaboxLoader3.resolve;dur=244.208148, load_resource;dur=247.165810
x-app-server: wwwb-app219
x-ts: 200
x-tr: 574
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=0
x-location: All
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
content-encoding: gzip
clemens's localized_dates at master - GitHub
This service is courtesy of Pledgie.
clemens / localized_dates
- Source
- Commits
- Network (4)
- Issues (1)
- Downloads (0)
- Wiki (1)
- Graphs
-
Branch:
master
click here to add a description
click here to add a homepage
Sending Request…
Enable Donations
Pledgie Donations
Once activated, we'll place the following badge in your repository's detail box:
Date and Time localization based on Rails' i18n functionalities — Read more
name | age | message | |
---|---|---|---|
![]() |
CHANGELOG | Thu Oct 02 05:00:21 -0700 2008 | Use Rails.logger instead of puts (Andreas Korth). [clemens] |
![]() |
README | Wed Dec 03 05:09:48 -0800 2008 | Update README. [clemens] |
![]() |
Rakefile | Sun Aug 03 13:02:37 -0700 2008 | initial import. [clemens] |
![]() |
init.rb | Fri Jul 10 08:07:15 -0700 2009 | Don't need init code anymore in Rails 2.3. [clemens] |
![]() |
install.rb | Fri Nov 21 02:17:42 -0800 2008 | use :en as a default locale (in favor of :en-US) [zargony] |
![]() |
lib/ | Sat Oct 31 06:09:42 -0700 2009 | Facilitate testing. [clemens] |
![]() |
spec/ | Sat Oct 31 06:09:42 -0700 2009 | Facilitate testing. [clemens] |
![]() |
tasks/ | Sun Aug 03 13:59:41 -0700 2008 | Added rake task for listing all installed locales. [clemens] |
README
localized_dates ================= The localized_dates plugin takes away some of the pain of localizing dates and times. It leverages the power of the Rails i18n plugin (https://rails-i18n.org/) to facilitate localization of dates and times. Installation ================= To install the plugin, change into an existing Rails application and run ruby script/plugin install git://github.com/clemens/localized_dates.git This will download the plugin and store it in vendor/plugins/localized_dates. It will also create a directory named config/locales and copy three locale files, en.rb, en.yml, and de.yml into this directory. While the "en" locale files mimic current Rails formats, "de" serves as a demo on how date and time formats can be customized. Adding a new locale ================= To add a new locale, simply create a new file in config/locales. You can make your life easier by copying an existing locale and basing your new locale on it. Adding new date and time formats ================= Adding new date and time formats is easy. Take a look at the basic structure of the locale file en.yml: en: date: formats: default: "%Y-%m-%d" short: "%e %b" long: "%B %e, %Y" only_day: "%e" time: formats: default: "%a %b %d %H:%M:%S %Z %Y" time: "%H:%M" short: "%d %b %H:%M" long: "%B %d, %Y %H:%M" only_second: "%S" datetime: formats: default: "%Y-%m-%dT%H:%M:%S%Z" am: 'am' pm: 'pm' As you can see, there are two basic entites: date and time. time also has two children, datetime and time_with_zone that both inherit from :time so you usually don't even need to define them (the "de" locale, for, example doesn't). If you need more complex Ruby constructs such as lambdas, you still need to define them in a separate Ruby file. Take a look at the following default formats of en.rb: { :en => { :date => { :formats => { :long_ordinal => lambda { |date| "%B #{date.day.ordinalize}, %Y" } } }, :time => { :formats => { :long_ordinal => lambda { |time| "%B #{time.day.ordinalize}, %Y %H:%M" } }, :time_with_zone => { :formats => { :default => lambda { |time| "%Y-%m-%d %H:%M:%S #{time.formatted_offset(false, 'UTC')}" } } } } } } For example, if you define a time format named release_date, you can use Time.now.to_s(:release_date) in your views. You should always define a format named default for both, date and time, that serves as the default format. You can use the default format by simply writing Time.now.to_s without passing an additional parameter. You can either use a strftime compatible formatting string or a Proc that returns a strftime formatting string as a date/time format. Take a look at the following examples: :short => "%d %B, %H:%M" # => "03 August, 22:49" :long => lambda { |time| "%A, #{time.day}. %B %Y, %H:%M" } # => "Samstag, 3. August 2008, 22:49" Please note that the use of Procs is slightly different from Rails' original behavior: old: :long => lambda { |time| time.strftime("%A, #{time.day}. %B %Y, %H:%M") } new: :long => lambda { |time| "%A, #{time.day}. %B %Y, %H:%M" } The old way should still work without throwing error messages, however, the dates and times will not be localized. For further information on strftime formatting, see https://ruby-doc.org/core/classes/Time.html#M000139. Check installed locales ================= To display a list of all locales installed in config/locales, you can use the following rake command: rake locales Customizing day and month names ================= If you localize your application for a language other than English, you most likely want to change the default month and day names to your own countries' names. Here's how it's done: de: date: day_names: [Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday] abbr_day_names: [Sun, Mon, Tue, Wed, Thu, Fri, Sat] month_names: [~, January, February, March, April, May, June, July, August, September, October, November, December] abbr_month_names: [~, Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec] order: [ :year, :month, :day ] The only caveat here is that month_names and abbr_month_names *need* nil as their respective first elements. If you don't use nil as the first element you'll end up with wrong dates (August will become September, etc.). Also note that the definition of day names starts with Sunday (not Monday). Changing the default locale ================= If you want to use a default locale other than "en", you have to tell the i18n plugin the locale you want to use by default. Simply put the following line in an initializer in config/initializers or include it in your environment.rb: I18n.default_locale = :de Contributors ================= * Aslak Hellesøy (https://blog.aslakhellesoy.com/) * Andreas Korth * Andreas Neuhaus Bugs and Feedback ================= If you discover any bugs I'd appreciate if you sent me an e-mail to clemens@railway.at. Please include a detailed description of your problem if you want me to help you. If you have positive feedback and want to drop me a line that's fine, too! :-) Copyright (c) 2008 Clemens Kofler <clemens@railway.at>, released under the MIT license https://www.railway.at https://github.com/clemens/localized_dates