|
Revision 5057, 0.9 kB
(checked in by hsbt, 11 months ago)
|
|
platform/tdiary/plugin: changed file encoding to UTF-8
|
| Line | |
|---|
| 1 | # jroku.rb $Revision: 1.1 $ |
|---|
| 2 | # |
|---|
| 3 | #「%R」で六曜を出す |
|---|
| 4 | # 動かすためには |
|---|
| 5 | # http://www.funaba.org/calendar.html#calendar |
|---|
| 6 | # で配布されているClendarモジュールと付属しているcalclass.rbが必要 |
|---|
| 7 | # 日付フォーマットなどで「%R」を指定するとそこが六曜になる |
|---|
| 8 | # |
|---|
| 9 | # Copyright (c) 2005 SHIBATA Hiroshi <h-sbt@nifty.com> |
|---|
| 10 | # You can distribute this file under the GPL. |
|---|
| 11 | # |
|---|
| 12 | require 'calclass.rb' |
|---|
| 13 | |
|---|
| 14 | unless Time::new.respond_to?( :strftime_jroku_backup ) then |
|---|
| 15 | eval( <<-MODIFY_CLASS, TOPLEVEL_BINDING ) |
|---|
| 16 | class Time |
|---|
| 17 | alias strftime_jroku_backup strftime |
|---|
| 18 | JROKU = %w(大安 赤口 先勝 友引 先負 仏滅) |
|---|
| 19 | |
|---|
| 20 | def strftime( format ) |
|---|
| 21 | d=Gregorian.new(self.month, self.day, self.year) |
|---|
| 22 | q_d = Calendar.kyureki_from_absolute(d.abs) |
|---|
| 23 | index = (q_d[0] + q_d[2]) % 6 |
|---|
| 24 | strftime_jroku_backup( format.gsub( /%R/, JROKU[index] ) ) |
|---|
| 25 | end |
|---|
| 26 | end |
|---|
| 27 | MODIFY_CLASS |
|---|
| 28 | end |
|---|