Chinese Luni-Solar Calendar
天正冬至月から1年分の翻訳表の取得
y : 年 returns : [When::Coordinates::Pair] 天正冬至月から1年分の翻訳表
# File when/region/chinese.rb, line 121 121: def _base_ids_(y) 122: _intercalary_pattern(y,12)[1..1].inject([Pair._force_pair(@base_month, 0)]) do |base_ids, flag| 123: base_ids << (flag ? Pair._force_pair(base_ids[1].trunk, 1) : Pair._force_pair(base_ids[1].trunk % 12 + 1, 0)) 124: end 125: end
天正冬至月の通月
y : 年 returns : 天正冬至月の通月
# File when/region/chinese.rb, line 94 94: def _base_month_(y) 95: (Residue.mod((@formula[0].cn_to_time(12*(y-1) + @base_month - @vernal_month) + 0.5 + @timezone[0]).floor) {|m| 96: _new_month(m) 97: })[0] 98: end
暦年の翻訳表の取得
date : [y] y - 年 returns : [When::Coordinates::Pair] 暦年の翻訳表
# File when/region/chinese.rb, line 108 108: def _ids_(date) 109: y = +date[0] 110: return _base_ids(y) if @base_month == 1 111: (_base_ids(y).dup.delete_if {|v| v.trunk >= @base_month}) + (_base_ids(y+1).dup.delete_if {|v| v.trunk < @base_month}) 112: end
指定の月の中気の有無
m : 通月 returns : Boolean true - 中気無し false - 中気有り
# File when/region/chinese.rb, line 160 160: def _intercalary?(m) 161: e = _new_month(m+1) - 1 162: d = Residue.mod(e) {|n| _new_epoch(n)} 163: e - d[1] < _new_month(m) 164: end
天正冬至月から1年分の閏月のパターンの取得
y : 年 returns : [Boolean] true - 閏月である false - 閏月でない
# File when/region/chinese.rb, line 135 135: def _intercalary_pattern(y, n) 136: m0 = _base_month(y) 137: m1 = _base_month(y + n/12.0) 138: return Array.new(n, false) if m1-m0 == n 139: return Array.new(n+1) {|i| i==@intercalary_month} if @intercalary_month # for 四分暦 140: return _intercalary_pattern(y, n/2) + _intercalary_pattern(y + n/24.0, n/2) if n > @intercalary_span 141: flags = Array.new(n+1, false) 142: n.times do |i| 143: m0 += 1 144: if _intercalary?(m0) 145: flags[i+1] = true 146: return flags 147: end 148: end 149: raise ArgumrntError, "Intercalary month not found" 150: end
正月の通月
y : 年 returns : 正月の通月
# File when/region/chinese.rb, line 76 76: def _new_year_month_(y) 77: return _base_month(y) if @base_month == 1 78: intercalary = 0 79: _ids([y-1]).each do |v| 80: unless v.branch == 0 81: intercalary = v.trunk 82: break 83: end 84: end 85: _base_month(y) - @base_month + (intercalary>=@base_month ? 14 : 13) 86: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.