~ubuntu-branches/ubuntu/saucy/tdiary/saucy-proposed

« back to all changes in this revision

Viewing changes to contrib2/plugin/jyear.rb

  • Committer: Bazaar Package Importer
  • Author(s): Daigo Moriwaki
  • Date: 2011-04-11 21:53:16 UTC
  • mfrom: (1.2.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20110411215316-ih4gt4q8p29d2wf8
Tags: 3.0.1-1
* New upstream release (Closes: #542801, #594947)
* debian/control:
 - Bumped up Standards-Version to 3.9.1.
 - Updated version dependency.
* debian/tdiary-setup.rb: Followed the upstream changes, incorporating js and
  index.fcgi

Show diffs side-by-side

added added

removed removed

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