Converts Date and Time objects into Japanese weekday names in different formats (kanji, hiragana, katakana, short).
Add this line to your application's Gemfile:
gem 'youbi'And then execute:
$ bundle install
Or install it yourself as:
$ gem install youbi
The japanese_day method can be used with both Date and Time objects.
require "youbi"
date = Date.new(2025, 2, 10) # 月曜日
time = Time.new(2025, 2, 10, 12, 0, 0) # 月曜日
puts date.japanese_day # => "月曜日"
puts time.japanese_day # => "月曜日"The japanese_day(format: :○○) option allows you to get the weekday in different formats.
| Option | Example (Monday) |
|---|---|
:kanji |
"月曜日" |
:hiragana |
"げつようび" |
:katakana |
"ゲツヨウビ" |
:short |
"月" |
puts date.japanese_day(format: :hiragana) # => "げつようび"
puts date.japanese_day(format: :katakana) # => "ゲツヨウビ"
puts date.japanese_day(format: :short) # => "月"If you pass an invalid format to japanese_day, the gem will raise a Youbi::Error.
begin
date.japanese_day(format: :invalid_format)
rescue Youbi::Error => e
puts e.message # => "Invalid format: invalid_format"
endYou can run tests using RSpec:
bundle exec rspec
Bug reports and pull requests are welcome on GitHub at https://github.com/ryotaro-shirai/youbi. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.
The gem is available as open source under the terms of the MIT License.
Everyone interacting in the Youbi project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.