#17 new
Steve

I18n.localize: select format date vs. time

Reported by Steve | July 29th, 2009 @ 03:05 PM

At the moment i18n detects the format to use ('date.formats.' vs. 'time.formats'), by checking whether or not an object responds to :sec. Which is O.K.

But passing the usual Rails ActiveSupport::TimeWithZone to I18n.l doesn't give me an opportunity to say whether I want it to be formatted as a date or time, since it'll choose time (TimeWithZone.responds_to(:sec) == true) and and option 'type' does not exist.

This snippet solves the issue:

def localize(locale, object, format = :default, options={})


(...)


type = options[:type] || (object.respond_to?(:sec) ? 'time' : 'date')


if format === Symbol

format = lookup(locale, :"#{type}.formats.#{format}")



end
format = resolve(locale, object, format, options.merge(:raise => true))
(...)
end

Greetings, my friends! (Can your heart stand the shocking fact about I18n without gettext? -- A tribute to Criswell, the famous psychic telling the story about "Plan 9: From Outer Space." - a classic by Ed Wood.)

Comments and changes to this ticket

  • Props1976

    Props1976 December 23rd, 2018 @ 03:04 PM

    That is, unfortunately, is advancing in our general public quickly. There ought to be finished direction and mindfulness about the suicide in the public arena to ward off the general population from it. What's more, let them back towards life. Check this essay writer service which will help you in your life.

  • david001

    david001 September 13th, 2019 @ 05:51 PM

    Get Unlimited hacks Apps with Amazing Ttips&Tricks https://itrickytech.com/

  • Walaim Henry

    Walaim Henry March 19th, 2023 @ 04:27 PM

    Organizing your refrigerator is a simple and easy task that can make a huge difference in how your food is stored and how quickly you can find what you need. Follow these tips and tricks to keep your refrigerator organized and maximize its storage space. https://refrigeratorshouse.com/best-apartment-size-refrigerator/

  • lindamartn15 (at gmail)

    lindamartn15 (at gmail) September 28th, 2023 @ 09:44 AM

    I’ve been recently thinking the very same matter personally lately. Happy to see a person on the same wavelength! Nice article. credit repair severna park

  • David Watson

    David Watson September 28th, 2023 @ 10:56 AM

    Tax Accounting Assignment Help is a valuable academic resource that provides assistance to students studying tax accounting. This specialized service is designed to support learners in comprehending and excelling in the complex field of tax accounting by offering expert guidance, clarification of concepts, and solutions to tax-related assignments and problems.

  • Kucingduit88

    Kucingduit88 July 4th, 2024 @ 09:07 AM

    Kaya303 adalah pilihan terbaik bagi para penggemar slot online yang mencari pengalaman bermain yang menyenangkan dan penuh keuntungan. Dengan Kaya303 login, Anda bisa langsung mengakses berbagai macam permainan slot yang seru dan menarik. kaya303 slot memiliki berbagai fitur bonus yang bisa membantu Anda meraih kemenangan besar. Bergabunglah dengan Kaya303 dan nikmati sensasi bermain slot yang luar biasa.

  • srikayamanis

    srikayamanis July 4th, 2024 @ 11:17 AM

    Situs Slot Online Kaya 303 memastikan bahwa informasi tentang permainan, promosi, dan berita terbaru selalu tersedia dan mudah diakses oleh pemain. Dengan demikian, pemain selalu mendapatkan informasi terkini yang mereka butuhkan.

  • Monyetsakti107

    Monyetsakti107 July 5th, 2024 @ 01:53 PM

    Kaya303 adalah platform slot online yang menawarkan berbagai jenis permainan menarik dan menguntungkan. Di kaya303 slot, Anda bisa menikmati permainan dengan grafis yang memukau dan fitur-fitur bonus yang menggiurkan. Kaya303 menyediakan antarmuka yang user-friendly dan proses pendaftaran yang mudah, menjadikannya pilihan terbaik bagi para pemain slot.

  • nigaho1640

    nigaho1640 July 10th, 2024 @ 03:18 PM

    Kaya303 adalah situs slot online yang menghadirkan berbagai permainan seru dengan grafis memukau dan peluang menang besar. Anda bisa dengan mudah login di Kaya303 untuk menikmati semua permainan favorit Anda. Bagi yang belum memiliki akun, proses daftar di Kaya303 sangat cepat dan mudah, memungkinkan Anda untuk segera bergabung dan menikmati berbagai bonus menarik. Bergabunglah sekarang dan rasakan pengalaman bermain yang mengasyikkan di Kaya303.

  • alex

    alex July 15th, 2024 @ 11:03 PM

    Check for your sephora gift card balancein the online portal, in store or while on the move. You can check your balance right now by scratching the gift card's pin Card by exposing the 16-digit number of the card and PIN code. With these codes, you can access your balance fast and efficiently.check sephora gift card balance,check vanilla gift card balance,

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Internationalization API for Ruby.

This library is used in Ruby on Rails but also suited for use in other contexts.

People watching this ticket

Pages