月日の配当パターンの種類が限定されている暦の抽象基底クラス
Calendar which has some fixed arrangement rules for under year 新年の日付が専用メソッドで与えられ、月日の配当が1年の日数等 で決まる暦。いわゆる Rule-Based な暦はほとんど該当します。
年月日 -> 通日
y - 年 m - 月 (0 始まり) d - 日 (0 始まり) returns : 通日
# File when/calendartypes.rb, line 138 138: def _coordinates_to_number(y, m, d) 139: sdn = _sdn([+y]) 140: rule = _rule(_key([+y])) 141: sdn += d + rule['Offset'][m] 142: return sdn if d >= 0 143: return sdn + rule['Length'][m % rule['Length'].length] 144: end
日時要素の翻訳表の取得
date : [y] y - 年 returns : [When::Coordinates::Pair] 日時要素の翻訳表
# File when/calendartypes.rb, line 257 257: def _ids_(date) 258: _rule(_key(date))['IDs'] 259: end
暦日表のキー取得
date : [y] y - 年 returns : 暦日表のキー 本暦法では当該年の日数を暦日表のキーとします
# File when/calendartypes.rb, line 243 243: def _key_(date) 244: n_date = date.dup 245: n_date[1] += 1 246: _sdn(n_date) - _sdn(date) 247: end
暦要素数
引数パターン1 date : [y] y - 年 returns : その年の月数 引数パターン2 date : [y, m] y - 年 m - 月 (0 始まり) returns : その年月の日数
# File when/calendartypes.rb, line 180 180: def _length(date) 181: y, m = date 182: if (m) 183: # 指定した月に含まれる日の数を返します。 184: return @unit[2] if @unit[2] 185: rule = _rule(_key([y])) 186: return rule['Length'][m % rule['Length'].length] 187: else 188: # 指定した年に含まれる月の数を返します。 189: return @unit[1] if @unit[1] 190: return _rule(_key([y]))['Months'] 191: end 192: end
通日 - > 年月日
sdn : 通日 returns : [y, m, d] y - 年 m - 月 (0 始まり) d - 日 (0 始まり)
# File when/calendartypes.rb, line 155 155: def _number_to_coordinates(sdn) 156: y, d = Residue.mod(sdn) {|n| _sdn([n])} 157: rule = _rule(_key([y])) 158: (rule['Months']-1).downto(0) do |m| 159: if d >=rule['Offset'][m] 160: d -= rule['Offset'][m] 161: return [y, m, d] 162: end 163: end 164: return nil 165: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.