/usr/share/tdiary/contrib/plugin/jyear.rb is in tdiary-contrib 5.0.8-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | # jyear.rb $Revision: 1.1 $
#
# 西暦を和暦に変換するプラグイン。
# 日記やツッコミの日付フォーマットで使う。
# 「%Y」で「2005」のところを、「%K」で「平成17」と表示。
# pluginに入れるだけで動作する。
#
# Copyright (c) 2005 sasasin/SuzukiShinnosuke<sasasin@sasasin.sytes.net>
# You can distribute this file under the GPL.
#
unless Time::new.respond_to?( :strftime_jyear_backup ) then
eval( <<-MODIFY_CLASS, TOPLEVEL_BINDING )
class Time
alias strftime_jyear_backup strftime
def strftime( format )
case self.year
when 0 .. 1926
gengo = "昔々"
if self.year == 1926 && self.month == 12 && self.day >=25 then
gengo = "昭和元年"
end
when 1927 .. 1989
jyear = self.year - 1925
gengo = "昭和" + jyear.to_s
if self.year == 1989 && self.month == 1 && self.day >= 8 then
gengo = "平成元年"
end
else
jyear = self.year - 1988
gengo = "平成" + jyear.to_s
end
strftime_jyear_backup( format.gsub( /%K/, gengo ) )
end
end
MODIFY_CLASS
end
|