Module: When::Coordinates

Included in:
TM::Calendar, TM::Clock, TM::PeriodDuration, TM::TemporalPosition, TM::TemporalPosition, V::Event::Enumerator
Defined in:
lib/when_exe/coordinates.rb,
lib/when_exe/region/bahai.rb,
lib/when_exe/region/mayan.rb,
lib/when_exe/region/indian.rb,
lib/when_exe/region/chinese.rb,
lib/when_exe/region/residue.rb,
lib/when_exe/region/tibetan.rb,
lib/when_exe/region/balinese.rb,
lib/when_exe/region/javanese.rb,
lib/when_exe/region/japanese_residues.rb,
lib/when_exe/inspect.rb,
lib/when_exe.rb

Overview

Copyright (C) 2012-2014 Takashi SUGA

You may use and/or modify this file according to the license described in the LICENSE.txt file included in this archive.

Defined Under Namespace

Modules: Temporal Classes: Branch, Index, Kyusei, LeapSeconds, Pair, Residue, Spatial, Stem, StemBranch, Wuku

Constant Summary collapse

PRECISION =

変換テーブル

{'YEAR'=>When::YEAR, 'MONTH' =>When::MONTH,  'WEEK'  =>When::WEEK,   'DAY'   =>When::DAY,
'HOUR'=>When::HOUR, 'MINUTE'=>When::MINUTE, 'SECOND'=>When::SECOND, 'SYSTEM'=>When::SYSTEM}
PERIOD =
{'P1Y' =>When::YEAR, 'P1M'   =>When::MONTH,  'P1W'   =>When::WEEK,   'P1D'   =>When::DAY,
'PT1H'=>When::HOUR, 'PT1M'  =>When::MINUTE, 'PT1S'  =>When::SECOND,
'1Y'  =>When::YEAR, '1M'    =>When::MONTH,  '1W'    =>When::WEEK,   '1D'    =>When::DAY,
'1h'  =>When::HOUR, '1m'    =>When::MINUTE, '1s'    =>When::SECOND}
VALUE =

RFC 5545

{'DATE'=>When::DAY,  'TIME'  =>When::SYSTEM, 'DATE-TIME'=>When::SYSTEM}
PRECISION_NAME =
PRECISION.invert
PERIOD_NAME =
{When::YEAR=>'P1Y' , When::MONTH=>'P1M',   When::WEEK  =>'P1W', When::DAY=>'P1D',
When::HOUR=>'PT1H', When::MINUTE=>'PT1M', When::SECOND=>'PT1S'}
MATCH =
{'NS'=>/(N|S|北緯|南緯)/, 'EW'=>/(E|W|東経|西経)/}
Bahai =

Bahai years

[When::BasicTypes::M17n, [
  "namespace:[en=http://en.wikipedia.org/wiki/, ja=http://ja.wikipedia.org/wiki/, ar=http://ar.wikipedia.org/wiki/]",
  "locale:[=en:, ar=ar:, alias=en:]",
  "names:[Bahai]",

  [Residue,
    "label:[YearName]", "divisor:19", "year:0", "format:[%1$s(%3$d)]",
    [Residue, "label:[Alif=,   ألف=,   A=            ]", "remainder:  0"],
    [Residue, "label:[Bá=,     باء=,   B=            ]", "remainder:  1"],
    [Residue, "label:[Ab=,     أب=,    Father=       ]", "remainder:  2"],
    [Residue, "label:[Dál=,    دﺍﻝ=,   D=            ]", "remainder:  3"],
    [Residue, "label:[Báb=,    باب=,   Gate=         ]", "remainder:  4"],
    [Residue, "label:[Váv=,    وﺍو=,   V=            ]", "remainder:  5"],
    [Residue, "label:[Abad=,   أبد=,   Eternity=     ]", "remainder:  6"],
    [Residue, "label:[Jád=,    جاد=,   Generosity=   ]", "remainder:  7"],
    [Residue, "label:[Bahá'=,  بهاء=,  Splendour=    ]", "remainder:  8"],
    [Residue, "label:[Ḥubb=,   حب=,    Love=         ]", "remainder:  9"],
    [Residue, "label:[Bahháj=, بهاج=,  Delightful=   ]", "remainder: 10"],
    [Residue, "label:[Javáb=,  جواب=,  Answer=       ]", "remainder: 11"],
    [Residue, "label:[Aḥad=,   احد=,   Single=       ]", "remainder: 12"],
    [Residue, "label:[Vahháb=, بهاء=,  Bountiful=    ]", "remainder: 13"],
    [Residue, "label:[Vidád=,  وداد=,  Affection=    ]", "remainder: 14"],
    [Residue, "label:[Badí‘=, بدیع=,  Beginning=    ]", "remainder: 15"],
    [Residue, "label:[Bahí=,   بهي=,   Luminous=     ]", "remainder: 16"],
    [Residue, "label:[Abhá=,   ابهى=,  Most Luminous=]", "remainder: 17"],
    [Residue, "label:[Váḥid=,  واحد=,  Unity=        ]", "remainder: 18"]
  ]
]]
Mayan =

Mayan Residue

[{'Epoch' => {'0D'=>{'Haab'=>'-65', 'Trecena'=> '8', 'Tzolkin'=>'4', 'LoN'=>'3'},
                      '2D'=>{'Haab'=>'-63', 'Trecena'=>'10', 'Tzolkin'=>'6', 'LoN'=>'5'}}}, BasicTypes::M17n, [
  "namespace:[en=http://en.wikipedia.org/wiki/, ja=http://ja.wikipedia.org/wiki/]",
  "locale:[=en:, ja=ja:, alias]",
  "names:[Mayan]",

  [Residue,
    "label:[Haab', ハアブ, Haab]", "divisor:365", 'day:#{Haab:-65}', "format:[%2$d%1$s/365]",
    "namespace:[glyph=http://en.wikipedia.org/wiki/File:Maya-]",
    [Residue, "label:[Pop     =glyph:Pop.jpg,            ポプ,       Pop   ]", "remainder:  0"],
    [Residue, "label:[Wo'     =glyph:Dresden-wo.jpg,     ウオ,       Wo    ]", "remainder: 20"],
    [Residue, "label:[Sip     =glyph:Dresden-sip.jpg,    シプ,       Sip   ]", "remainder: 40"],
    [Residue, "label:[Sotz'   =glyph:Sotz.jpg,           ソッツ,     Sotz  ]", "remainder: 60"],
    [Residue, "label:[Sek     =glyph:Dresden-Sek.jpg,    セック,     Sek   ]", "remainder: 80"],
    [Residue, "label:[Xul     =glyph:Xul.png,            シュル,     Xul   ]", "remainder:100"],
    [Residue, "label:[Yaxk'in'=glyph:Dresden-Yaxkin.jpg, ヤシュキン, Yaxkin]", "remainder:120"],
    [Residue, "label:[Mol     =glyph:Mol.png,            モル,       Mol   ]", "remainder:140"],
    [Residue, "label:[Ch'en   =glyph:Dresden-Chen.jpg,   チェン,     Chen  ]", "remainder:160"],
    [Residue, "label:[Yax     =glyph:Dresden-Yax.jpg,    ヤシュ,     Yax   ]", "remainder:180"],
    [Residue, "label:[Sak'    =glyph:Dresden-Sak.jpg,    サック,     Sak   ]", "remainder:200"],
    [Residue, "label:[Keh     =glyph:Dresden-Keh.jpg,    ケフ,       Keh   ]", "remainder:220"],
    [Residue, "label:[Mak     =glyph:Dresden-Mak.png,    マック,     Mak   ]", "remainder:240"],
    [Residue, "label:[K'ank'in=glyph:Dresden-Kankin.png, カンキン,   Kankin]", "remainder:260"],
    [Residue, "label:[Muwan'  =glyph:Muan.jpg,           ムアン,     Muwan ]", "remainder:280"],
    [Residue, "label:[Pax     =glyph:Dresden-pax.jpg,    パシュ,     Pax   ]", "remainder:300"],
    [Residue, "label:[K'ayab  =glyph:Dresden-Kayab.png,  カヤブ,     Kayab ]", "remainder:320"],
    [Residue, "label:[Kumk'u  =glyph:Dresden-kumku.jpg,  クムク,     Kumku ]", "remainder:340"],
    [Residue, "label:[Wayeb'  =glyph:Dresden-wayeb.jpg,  ウェヤブ,   Wayeb ]", "remainder:360"]
  ],

  [Residue,
    "label:[Trecena, トレセナ=, Trecena]", "divisor:13", 'day:#{Trecena:8}', "format:[%1$s(%3$d/13)]"
  ],

  [Residue,
    "namespace:[glyph=http://en.wikipedia.org/wiki/File:MAYA-g-log-cal-]",
    "label:[Tzolk'in, ツォルキン, Tzolkin]", "divisor:20", 'day:#{Tzolkin:4}', "format:[%s(%d/20)]",
    [Residue, "label:[Imix'   =glyph:D01-Imix.png,     イミシュ,   Imix    =glyph:D01-Imix-cdxW.png    ]", "remainder: 0"],
    [Residue, "label:[Ik'     =glyph:D02-Ik.png,       イック,     Ik      =glyph:D02-Ik-cdxW.png      ]", "remainder: 1"],
    [Residue, "label:[Ak'b'al =glyph:D03-Akbal.png,    アクバル,   Akbal   =glyph:D03-Akbal-cdxW.png   ]", "remainder: 2"],
    [Residue, "label:[K'an    =glyph:D04-Kan.png,      カン,       Kan     =glyph:D04-Kan-cdxW.png     ]", "remainder: 3"],
    [Residue, "label:[Chikchan=glyph:D05-Chikchan.png, チクチャン, Chicchan=glyph:D05-Chikchan-cdxW.png]", "remainder: 4"],
    [Residue, "label:[Kimi    =glyph:D06-Kimi.png,     キミ,       Cimi    =glyph:D06-Kimi-cdxW.png    ]", "remainder: 5"],
    [Residue, "label:[Manik'  =glyph:D07-Manik.png,    マニク,     Manik   =glyph:D07-Manik-cdxW.png   ]", "remainder: 6"],
    [Residue, "label:[Lamat   =glyph:D08-Lamat.png,    ラマト,     Lamat   =glyph:D08-Lamat-cdxW.png   ]", "remainder: 7"],
    [Residue, "label:[Muluk   =glyph:D09-Muluk.png,    ムルク,     Muluc   =glyph:D09-Muluk-cdxW.png   ]", "remainder: 8"],
    [Residue, "label:[Ok      =glyph:D10-Ok.png,       オック,     Oc      =glyph:D10-Ok-cdxW.png      ]", "remainder: 9"],
    [Residue, "label:[Chuwen  =glyph:D11-Chuwen.png,   チュエン,   Chuen   =glyph:D11-Chuwen-cdxW.png  ]", "remainder:10"],
    [Residue, "label:[Eb'     =glyph:D12-Eb.png,       エブ,       Eb      =glyph:D12-Eb-cdxW.png      ]", "remainder:11"],
    [Residue, "label:[B'en    =glyph:D13-Ben.png,      ベン,       Ben     =glyph:D13-Ben-cdxW.png     ]", "remainder:12"],
    [Residue, "label:[Ix      =glyph:D14-Ix.png,       イシュ,     Ix      =glyph:D14-Ix-cdxW.png      ]", "remainder:13"],
    [Residue, "label:[Men     =glyph:D15-Men.png,      メン,       Men     =glyph:D15-Men-cdxW.png     ]", "remainder:14"],
    [Residue, "label:[Kib'    =glyph:D16-Kib.png,      キッブ,     Cib     =glyph:D16-Kib-cdxW.png     ]", "remainder:15"],
    [Residue, "label:[Kab'an  =glyph:D17-Kaban.png,    カーバン,   Caban   =glyph:D17-Kaban-cdxW.png   ]", "remainder:16"],
    [Residue, "label:[Etz'nab'=glyph:D18-Etznab.png,   エツナブ,   Etznab  =glyph:D18-Etznab-cdxW.png  ]", "remainder:17"],
    [Residue, "label:[Kawak   =glyph:D19-Kawak.png,    カワク,     Cauac   =glyph:D19-Kawak-cdxW.png   ]", "remainder:18"],
    [Residue, "label:[Ajaw    =glyph:D20-Ajaw.png,     アハウ,     Ahau    =glyph:D20-Ajaw-cdxW.png    ]", "remainder:19"],
  ],

  [Residue,
    "namespace:[glyph=http://www.pauahtun.org/G/G]",
    "label:[Lords_of_the_Night, 夜の九王]", "divisor:9", 'day:#{LoN:3}', "format:[%s(%d/9)]",
    [Residue, "label:[G9=glyph:9_m.png]", "remainder: 0"],
    [Residue, "label:[G1=glyph:1_m.png]", "remainder: 1"],
    [Residue, "label:[G2=glyph:2_m.png]", "remainder: 2"],
    [Residue, "label:[G3=glyph:3_m.png]", "remainder: 3"],
    [Residue, "label:[G4=glyph:4_m.png]", "remainder: 4"],
    [Residue, "label:[G5=glyph:5_m.png]", "remainder: 5"],
    [Residue, "label:[G6=glyph:6_m.png]", "remainder: 6"],
    [Residue, "label:[G7=glyph:7_m.png]", "remainder: 7"],
    [Residue, "label:[G8=glyph:8_m.png]", "remainder: 8"],
  ],
]]
IndianCities =

Location of cities in India

[When::BasicTypes::M17n, [
  "namespace:[en=http://en.wikipedia.org/wiki/, ja=http://ja.wikipedia.org/wiki/]",
  "locale:[=en:, ja=ja:, alias]",
  "names:[IndianCities]",
  [Spatial, "long:+82.5", "lat:N23.11", "label:[CentralIndia,       インド中部]"          ],
  [Spatial, "long:+82.5", "lat:+29.0",  "label:[NorthIndia,         インド北部]"          ],
  [Spatial, "long:+78.0", "lat:+27.2",  "label:[Agra,               アーグラ]"            ],
  [Spatial, "long:+72.6", "lat:+23.0",  "label:[Ahmedabad,          アフマダーバード]"    ],
  [Spatial, "long:+74.6", "lat:+26.5",  "label:[Ajmer,              アジメール]"          ],
  [Spatial, "long:+78.1", "lat:+27.9",  "label:[Aligarh,            アリーガル]"          ],
  [Spatial, "long:+74.9", "lat:+31.6",  "label:[Amritsar,           アムリトサル]"        ],
  [Spatial, "long:+77.6", "lat:+13.0",  "label:[Bangalore,          バンガロール]"        ],
  [Spatial, "long:+85.8", "lat:+20.2",  "label:[Bhuvaneswar,        ブヴァネーシュヴァル]"],
  [Spatial, "long:+80.3", "lat:+13.1",  "label:[Chennai,            チェンナイ, Madras]"  ],
  [Spatial, "long:+79.9", "lat: +6.9",  "label:[Colombo,            コロンボ]"            ],
  [Spatial, "long:+90.4", "lat:+23.7",  "label:[Dacca,              ダッカ]"              ],
  [Spatial, "long:+77.2", "lat:+28.6",  "label:[Delhi,              デリー]"              ],
  [Spatial, "long:+78.5", "lat:+17.4",  "label:[Hyderabad,          ハイデラバード]"      ],
  [Spatial, "long:+75.8", "lat:+26.9",  "label:[Jaipur,             ジャイプル]"          ],
  [Spatial, "long:+85.2", "lat:+27.7",  "label:[Kathmandu,          カトマンズ]"          ],
  [Spatial, "long:+76.2", "lat:+10.0",  "label:[Kochi,              コーチ, Cochin]"      ],
  [Spatial, "long:+88.4", "lat:+22.6",  "label:[Kolkata,            コルカタ, Calcutta]"  ],
  [Spatial, "long:+74.3", "lat:+31.6",  "label:[Lahor,              ラホール]"            ],
  [Spatial, "long:+77.7", "lat:+27.5",  "label:[Mathura,            マトゥラー]"          ],
  [Spatial, "long:+72.8", "lat:+19.0",  "label:[Mumbai,             ムンバイ, Bombay]"    ],
  [Spatial, "long:+76.6", "lat:+12.3",  "label:[Mysore,             マイソール]"          ],
  [Spatial, "long:+85.1", "lat:+25.6",  "label:[Patna,              パトナ]"              ],
  [Spatial, "long:+73.9", "lat:+18.5",  "label:[Pune,               プネー]"              ],
  [Spatial, "long:+74.8", "lat:+34.1",  "label:[Srinagar,           シュリーナガル]"      ],
  [Spatial, "long:+77.0", "lat: +8.5",  "label:[Thiruvananthapuram, ティルヴァナンタプラム, Trivandrum]"],
  [Spatial, "long:+83.0", "lat:+25.3",  "label:[Varanasi,           ワーラーナシー]"      ],
  [Spatial, "long:+75.8", "lat:+23.2",  "label:[Ujjain,             ウッジャイン]"        ]
]]
Yi =

Yi years

[When::BasicTypes::M17n, [
  "namespace:[en=http://en.wikipedia.org/wiki/, ja=http://ja.wikipedia.org/wiki/]",
  "locale:[=ja:, en=en:, alias]",
  "names:[Yi]",

  [Residue,
    "label:[YearName]", "divisor:8", "year:0",
    [Residue, "label:[東北之年=, NorthEastYear=]", "remainder:  0"],
    [Residue, "label:[東方之年=, EastYear=     ]", "remainder:  1"],
    [Residue, "label:[東南之年=, SouthEastYear=]", "remainder:  2"],
    [Residue, "label:[南方之年=, SouthYear=    ]", "remainder:  3"],
    [Residue, "label:[西南之年=, SouthWestYear=]", "remainder:  4"],
    [Residue, "label:[西方之年=, WestYear=     ]", "remainder:  5"],
    [Residue, "label:[西北之年=, NorthWestYear=]", "remainder:  6"],
    [Residue, "label:[北方之年=, NorthYear=    ]", "remainder:  7"]
  ]
]]
CommonResidue =

Common Residue

[{'V'=>{'0618'=>{'A'=>'awakening_of_insects=,*啓蟄',
                                 'B'=>'rain_water=,*雨水'}}}, When::BasicTypes::M17n, [
  "namespace:[en=http://en.wikipedia.org/wiki/, ja=http://ja.wikipedia.org/wiki/]",
  "locale:[=en:, ja=ja:, tenreki, tibetan, yi, alias]",
  "names:[CommonResidue]",

  [Residue,
    "label:[Week, 週]", "divisor:7", "day:0",
    [Residue, "label:[Monday,    月曜日, /date/day_names/1]", "remainder:0"],
    [Residue, "label:[Tuesday,   火曜日, /date/day_names/2]", "remainder:1"],
    [Residue, "label:[Wednesday, 水曜日, /date/day_names/3]", "remainder:2"],
    [Residue, "label:[Thursday,  木曜日, /date/day_names/4]", "remainder:3"],
    [Residue, "label:[Friday,    金曜日, /date/day_names/5]", "remainder:4"],
    [Residue, "label:[Saturday,  土曜日, /date/day_names/6]", "remainder:5"],
    [Residue, "label:[Sunday,    日曜日, /date/day_names/0]", "remainder:6"]
  ],

  [When::BasicTypes::M17n,
    "names:[Abbr_Day, 週日略称]",
    "[Mon, 月, /date/abbr_day_names/1] ",
    "[Tue, 火, /date/abbr_day_names/2] ",
    "[Wed, 水, /date/abbr_day_names/3] ",
    "[Thu, 木, /date/abbr_day_names/4] ",
    "[Fri, 金, /date/abbr_day_names/5] ",
    "[Sat, 土, /date/abbr_day_names/6] ",
    "[Sun, 日, /date/abbr_day_names/0] "
  ],

  [Residue,
    "locale:[=en:, ja=ja:, alias]",
    "label:[StarMansion, *宿]", "divisor:28", "day:17",   "format:[%s(%02d)]",
    [Residue, "label:[Horn=,            *角宿,  Jiăo= ]", "remainder:0"],  #  1 α Vir 
    [Residue, "label:[Neck=,            *亢宿,  Kàng= ]", "remainder:1"],  #  2 κ Vir 
    [Residue, "label:[Root=,            *氐宿,  Dĭ=   ]", "remainder:2"],  #  3 α Lib 
    [Residue, "label:[Room=,            *房宿,  Fáng= ]", "remainder:3"],  #  4 π Sco 
    [Residue, "label:[Heart=,           *心宿,  Xīn=  ]", "remainder:4"],  #  5 σ Sco 
    [Residue, "label:[Tail=,            *尾宿,  Wěi=  ]", "remainder:5"],  #  6 μ Sco 
    [Residue, "label:[WinnowingBasket=, *箕宿,  Jī=   ]", "remainder:6"],  #  7 γ Sgr 
    [Residue, "label:[SouthernDipper=,  *斗宿,  Dǒu= ]", "remainder:7"],  #  8 φ Sgr 
    [Residue, "label:[Ox=,              *牛宿,  Niú=  ]", "remainder:8"],  #  9 β Cap 
    [Residue, "label:[Girl=,            *女宿,  Nǚ=  ]", "remainder:9"],  # 10 ε Aqr 
    [Residue, "label:[Emptiness=,       *虛宿,  Xū=   ]", "remainder:10"], # 11 β Aqr 
    [Residue, "label:[Rooftop=,         *危宿,  Wēi=  ]", "remainder:11"], # 12 α Aqr 
    [Residue, "label:[Encampment=,      *室宿,  Shì=  ]", "remainder:12"], # 13 α Peg 
    [Residue, "label:[Wall=,            *壁宿,  Bì=   ]", "remainder:13"], # 14 γ Peg 
    [Residue, "label:[Legs=,            *奎宿,  Kuí=  ]", "remainder:14"], # 15 η And 
    [Residue, "label:[Bond=,            *婁宿,  Lóu=  ]", "remainder:15"], # 16 β Ari 
    [Residue, "label:[Stomach=,         *胃宿,  Wèi=  ]", "remainder:16"], # 17 35 Ari 
    [Residue, "label:[HairyHead=,       *昴宿,  Mǎo= ]", "remainder:17"], # 18 17 Tau 
    [Residue, "label:[Net=,             *畢宿,  Bì=   ]", "remainder:18"], # 19 ε Tau 
    [Residue, "label:[TurtleBeak=,      *觜宿,  Zī=   ]", "remainder:19"], # 20 λ Ori 
    [Residue, "label:[ThreeStars=,      *參宿,  Shēn= ]", "remainder:20"], # 21 ζ Ori 
    [Residue, "label:[Well=,            *井宿,  Jǐng=]", "remainder:21"], # 22 μ Gem 
    [Residue, "label:[Ghost=,           *鬼宿,  Guǐ= ]", "remainder:22"], # 23 θ Cnc 
    [Residue, "label:[Willow=,          *柳宿,  Liǔ= ]", "remainder:23"], # 24 δ Hya 
    [Residue, "label:[Star=,            *星宿,  Xīng= ]", "remainder:24"], # 25 α Hya 
    [Residue, "label:[ExtendedNet=,     *張宿,  Zhāng=]", "remainder:25"], # 26 υ¹ Hya
    [Residue, "label:[Wings=,           *翼宿,  Yì=   ]", "remainder:26"], # 27 α Crt 
    [Residue, "label:[Chariot=,         *軫宿,  Zhěn= ]", "remainder:27"]  # 28 γ Crv 
  ],

  [Stem,
    "label:[Stem, *干]", "divisor:10", "day:11", "year:4",
    [Stem, "label:[kinoe,      *甲, 甲, 木男, 木公]", "remainder:0"],
    [Stem, "label:[kinoto,     *乙, 乙, 木女, 木母]", "remainder:1"],
    [Stem, "label:[hinoe,      *丙, 丙, 火男, 火公]", "remainder:2"],
    [Stem, "label:[hinoto,     *丁, 丁, 火女, 火母]", "remainder:3"],
    [Stem, "label:[tsuchinoe,  *戊, 戊, 土男, 土公]", "remainder:4"],
    [Stem, "label:[tsuchinoto, *己, 己, 土女, 土母]", "remainder:5"],
    [Stem, "label:[kanoe,      *庚, 庚, 金男, 銅公]", "remainder:6"],
    [Stem, "label:[kanoto,     *辛, 辛, 金女, 銅母]", "remainder:7"],
    [Stem, "label:[mizunoe,    *壬, 壬, 水男, 水公]", "remainder:8"],
    [Stem, "label:[mizunoto,   *癸, 癸, 水女, 水母]", "remainder:9"]
  ],

  [Branch,
    "label:[Branch, *支]", "divisor:12", "day:11", "year:4",
    [Branch, "label:[ne,        *子, 子, 鼠, 鼠]", "remainder: 0"],
    [Branch, "label:[ushi,      *丑, 好, 牛, 牛]", "remainder: 1"],
    [Branch, "label:[tora,      *寅, 寅, 虎, 虎]", "remainder: 2"],
    [Branch, "label:[u,         *卯, 栄, 兎, 兎]", "remainder: 3"],
    [Branch, "label:[tatsu,     *辰, 辰, 龍, 龍]", "remainder: 4"],
    [Branch, "label:[mi,        *巳, 巳, 蛇, 蛇]", "remainder: 5"],
    [Branch, "label:[uma,       *午, 午, 馬, 馬]", "remainder: 6"],
    [Branch, "label:[hitsuji,   *未, 未, 羊, 羊]", "remainder: 7"],
    [Branch, "label:[saru,      *申, 申, 猴, 猴]", "remainder: 8"],
    [Branch, "label:[tori,      *酉, 酉, 鷄, 鷄]", "remainder: 9"],
    [Branch, "label:[inu,       *戌, 戌, 狗, 狗]", "remainder:10"],
    [Branch, "label:[i,         *亥, 開, 猪, 猪]", "remainder:11"]
  ],

  [StemBranch,
    "label:[Stem-Branch, *干支]", "divisor:60", "day:11", "year:4", "format:[%s(%02d)]",
    [StemBranch, "label:[kinoe-ne=,           *甲子, 甲子, 木男鼠, 木公鼠]", "remainder: 0"],
    [StemBranch, "label:[kinoto-ushi=,        *乙丑, 乙好, 木女牛, 木母牛]", "remainder: 1"],
    [StemBranch, "label:[hinoe-tora=,         *丙寅, 丙寅, 火男虎, 火公虎]", "remainder: 2"],
    [StemBranch, "label:[hinoto-u=,           *丁卯, 丁栄, 火女兎, 火母兎]", "remainder: 3"],
    [StemBranch, "label:[tsuchinoe-tatsu=,    *戊辰, 戊辰, 土男龍, 土公龍]", "remainder: 4"],
    [StemBranch, "label:[tsuchinoto-mi=,      *己巳, 己巳, 土女蛇, 土母蛇]", "remainder: 5"],
    [StemBranch, "label:[kanoe-uma=,          *庚午, 庚午, 金男馬, 銅公馬]", "remainder: 6"],
    [StemBranch, "label:[kanoto-hitsuji=,     *辛未, 辛未, 金女羊, 銅母羊]", "remainder: 7"],
    [StemBranch, "label:[mizunoe-saru=,       *壬申, 壬申, 水男猴, 水公猴]", "remainder: 8"],
    [StemBranch, "label:[mizunoto-tori=,      *癸酉, 癸酉, 水女鷄, 水母鷄]", "remainder: 9"],
    [StemBranch, "label:[kinoe-inu=,          *甲戌, 甲戌, 木男狗, 木公狗]", "remainder:10"],
    [StemBranch, "label:[kinoto-i=,           *乙亥, 乙開, 木女猪, 木母猪]", "remainder:11"],
    [StemBranch, "label:[hinoe-ne=,           *丙子, 丙子, 火男鼠, 火公鼠]", "remainder:12"],
    [StemBranch, "label:[hinoto-ushi=,        *丁丑, 丁好, 火女牛, 火母牛]", "remainder:13"],
    [StemBranch, "label:[tsuchinoe-tora=,     *戊寅, 戊寅, 土男虎, 土公虎]", "remainder:14"],
    [StemBranch, "label:[tsuchinoto-u=,       *己卯, 己栄, 土女兎, 土母兎]", "remainder:15"],
    [StemBranch, "label:[kanoe-tatsu=,        *庚辰, 庚辰, 金男龍, 銅公龍]", "remainder:16"],
    [StemBranch, "label:[kanoto-mi=,          *辛巳, 辛巳, 金女蛇, 銅母蛇]", "remainder:17"],
    [StemBranch, "label:[mizunoe-uma=,        *壬午, 壬午, 水男馬, 水公馬]", "remainder:18"],
    [StemBranch, "label:[mizunoto-hitsuji=,   *癸未, 癸未, 水女羊, 水母羊]", "remainder:19"],
    [StemBranch, "label:[kinoe-saru=,         *甲申, 甲申, 木男猴, 木公猴]", "remainder:20"],
    [StemBranch, "label:[kinoto-tori=,        *乙酉, 乙酉, 木女鷄, 木母鷄]", "remainder:21"],
    [StemBranch, "label:[hinoe-inu=,          *丙戌, 丙戌, 火男狗, 火公狗]", "remainder:22"],
    [StemBranch, "label:[hinoto-i=,           *丁亥, 丁開, 火女猪, 火母猪]", "remainder:23"],
    [StemBranch, "label:[tsuchinoe-ne=,       *戊子, 戊子, 土男鼠, 土公鼠]", "remainder:24"],
    [StemBranch, "label:[tsuchinoto-ushi=,    *己丑, 己好, 土女牛, 土母牛]", "remainder:25"],
    [StemBranch, "label:[kanoe-tora=,         *庚寅, 庚寅, 金男虎, 銅公虎]", "remainder:26"],
    [StemBranch, "label:[kanoto-u=,           *辛卯, 辛栄, 金女兎, 銅母兎]", "remainder:27"],
    [StemBranch, "label:[mizunoe-tatsu=,      *壬辰, 壬辰, 水男龍, 水公龍]", "remainder:28"],
    [StemBranch, "label:[mizunoto-mi=,        *癸巳, 癸巳, 水女蛇, 水母蛇]", "remainder:29"],
    [StemBranch, "label:[kinoe-uma=,          *甲午, 甲午, 木男馬, 木公馬]", "remainder:30"],
    [StemBranch, "label:[kinoto-hitsuji=,     *乙未, 乙未, 木女羊, 木母羊]", "remainder:31"],
    [StemBranch, "label:[hinoe-saru=,         *丙申, 丙申, 火男猴, 火公猴]", "remainder:32"],
    [StemBranch, "label:[hinoto-tori=,        *丁酉, 丁酉, 火女鷄, 火母鷄]", "remainder:33"],
    [StemBranch, "label:[tsuchinoe-inu=,      *戊戌, 戊戌, 土男狗, 土公狗]", "remainder:34"],
    [StemBranch, "label:[tsuchinoto-i=,       *己亥, 己開, 土女猪, 土母猪]", "remainder:35"],
    [StemBranch, "label:[kanoe-ne=,           *庚子, 庚子, 金男鼠, 銅公鼠]", "remainder:36"],
    [StemBranch, "label:[kanoto-ushi=,        *辛丑, 辛好, 金女牛, 銅母牛]", "remainder:37"],
    [StemBranch, "label:[mizunoe-tora=,       *壬寅, 壬寅, 水男虎, 水公虎]", "remainder:38"],
    [StemBranch, "label:[mizunoto-u=,         *癸卯, 癸栄, 水女兎, 水母兎]", "remainder:39"],
    [StemBranch, "label:[kinoe-tatsu=,        *甲辰, 甲辰, 木男龍, 木公龍]", "remainder:40"],
    [StemBranch, "label:[kinoto-mi=,          *乙巳, 乙巳, 木女蛇, 木母蛇]", "remainder:41"],
    [StemBranch, "label:[hinoe-uma=,          *丙午, 丙午, 火男馬, 火公馬]", "remainder:42"],
    [StemBranch, "label:[hinoto-hitsuji=,     *丁未, 丁未, 火女羊, 火母羊]", "remainder:43"],
    [StemBranch, "label:[tsuchinoe-saru=,     *戊申, 戊申, 土男猴, 土公猴]", "remainder:44"],
    [StemBranch, "label:[tsuchinoto-tori=,    *己酉, 己酉, 土女鷄, 土母鷄]", "remainder:45"],
    [StemBranch, "label:[kanoe-inu=,          *庚戌, 庚戌, 金男狗, 銅公狗]", "remainder:46"],
    [StemBranch, "label:[kanoto-i=,           *辛亥, 辛開, 金女猪, 銅母猪]", "remainder:47"],
    [StemBranch, "label:[mizunoe-ne=,         *壬子, 壬子, 水男鼠, 水公鼠]", "remainder:48"],
    [StemBranch, "label:[mizunoto-ushi=,      *癸丑, 癸好, 水女牛, 水母牛]", "remainder:49"],
    [StemBranch, "label:[kinoe-tora=,         *甲寅, 甲寅, 木男虎, 木公虎]", "remainder:50"],
    [StemBranch, "label:[kinoto-u=,           *乙卯, 乙栄, 木女兎, 木母兎]", "remainder:51"],
    [StemBranch, "label:[hinoe-tatsu=,        *丙辰, 丙辰, 火男龍, 火公龍]", "remainder:52"],
    [StemBranch, "label:[hinoto-mi=,          *丁巳, 丁巳, 火女蛇, 火母蛇]", "remainder:53"],
    [StemBranch, "label:[tsuchinoe-uma=,      *戊午, 戊午, 土男馬, 土公馬]", "remainder:54"],
    [StemBranch, "label:[tsuchinoto-hitsuji=, *己未, 己未, 土女羊, 土母羊]", "remainder:55"],
    [StemBranch, "label:[kanoe-saru=,         *庚申, 庚申, 金男猴, 銅公猴]", "remainder:56"],
    [StemBranch, "label:[kanoto-tori=,        *辛酉, 辛酉, 金女鷄, 銅母鷄]", "remainder:57"],
    [StemBranch, "label:[mizunoe-inu=,        *壬戌, 壬戌, 水男狗, 水公狗]", "remainder:58"],
    [StemBranch, "label:[mizunoto-i=,         *癸亥, 癸開, 水女猪, 水母猪]", "remainder:59"]
  ],

  [Kyusei,
    "locale:[=en:, ja=ja:]",
    "label:[Kyusei=, *九星]", "divisor:9", "year:7",
    [Kyusei, "label:[KyuushiKasei=,    *九紫火星]", "remainder:0"],
    [Kyusei, "label:[HappakuDosei=,    *八白土星]", "remainder:1"],
    [Kyusei, "label:[SichisekiKinsei=, *七赤金星]", "remainder:2"],
    [Kyusei, "label:[RoppakuKinsei=,   *六白金星]", "remainder:3"],
    [Kyusei, "label:[GoouDosei=,       *五黄土星]", "remainder:4"],
    [Kyusei, "label:[ShirokuMokusei=,  *四緑木星]", "remainder:5"],
    [Kyusei, "label:[SampekiMokusei=,  *三碧木星]", "remainder:6"],
    [Kyusei, "label:[JikokuDosei=,     *二黒土星]", "remainder:7"],
    [Kyusei, "label:[IppakuSuisei=,    *一白水星]", "remainder:8"]
  ],

  [Residue,
    "locale:[=en:, ja=ja:, alias]",
    "label:[SolarTerm=en:Solar_term, *二十四節気]", "divisor:360",
    [Residue, "label:[vernal_equinox=,          *春分, 二月中=]  ", "remainder:0"  ],
    [Residue, "label:[clear_and_bright=,        *清明, 三月節=]  ", "remainder:15" ],
    [Residue, "label:[grain_rain=,              *穀雨, 三月中=]  ", "remainder:30" ],
    [Residue, "label:[start_of_summer=,         *立夏, 四月節=]  ", "remainder:45" ],
    [Residue, "label:[grain_full=,              *小満, 四月中=]  ", "remainder:60" ],
    [Residue, "label:[grain_in_ear=,            *芒種, 五月節=]  ", "remainder:75" ],
    [Residue, "label:[summer_solstice=,         *夏至, 五月中=]  ", "remainder:90" ],
    [Residue, "label:[minor_heat=,              *小暑, 六月節=]  ", "remainder:105"],
    [Residue, "label:[major_heat=,              *大暑, 六月中=]  ", "remainder:120"],
    [Residue, "label:[start_of_autumn=,         *立秋, 七月節=]  ", "remainder:135"],
    [Residue, "label:[limit_of_heat=,           *処暑, 七月中=]  ", "remainder:150"],
    [Residue, "label:[white_dew=,               *白露, 八月節=]  ", "remainder:165"],
    [Residue, "label:[autumnal_equinox=,        *秋分, 八月中=]  ", "remainder:180"],
    [Residue, "label:[cold_dew=,                *寒露, 九月節=]  ", "remainder:195"],
    [Residue, "label:[frost_descent=,           *霜降, 九月中=]  ", "remainder:210"],
    [Residue, "label:[start_of_winter=,         *立冬, 十月節=]  ", "remainder:225"],
    [Residue, "label:[minor_snow=,              *小雪, 十月中=]  ", "remainder:240"],
    [Residue, "label:[major_snow=,              *大雪, 十一月節=]", "remainder:255"],
    [Residue, "label:[winter_solstice=,         *冬至, 十一月中=]", "remainder:270"],
    [Residue, "label:[minor_cold=,              *小寒, 十二月節=]", "remainder:285"],
    [Residue, "label:[major_cold=,              *大寒, 十二月中=]", "remainder:300"],
    [Residue, "label:[start_of_spring=,         *立春, 正月節=]  ", "remainder:315"],
    [Residue, 'label:[#{A:rain_water=,          *雨水},正月中=]  ', "remainder:330"], # 戊寅・儀鳳暦では啓蟄
    [Residue, 'label:[#{B:awakening_of_insects=,*啓蟄},二月節=]  ', "remainder:345"]  # 戊寅・儀鳳暦では雨水
  ],

  [Residue,
    "locale:[=en:, ja=ja:]",
    "label:[LunarPhase=en:Lunar_phase, *月相]", "divisor:360",
    [Residue, "label:[New_moon=,           *朔  ]", "remainder:0"  ],
    [Residue, "label:[First_quarter_moon=, *上弦]", "remainder:90" ],
    [Residue, "label:[Full_moon=,          *望  ]", "remainder:180"],
    [Residue, "label:[Third_quarter_moon=, *下弦]", "remainder:270"]
  ]
]]
Tibetan =

六十干支

[When::BasicTypes::M17n, [
  "namespace:[en=http://en.wikipedia.org/wiki/, ja=http://ja.wikipedia.org/wiki/]",
  "locale:[=en:, ja=ja:, alias]",
  "names:[Tibetan]",

  [StemBranch,
    "label:[Stem-Branch, *干支]", "divisor:60", "day:11", "year:4",
    [StemBranch, "label:[Wood-Rat=,      *木男鼠=]", "remainder: 0"],
    [StemBranch, "label:[Wood-Ox=,       *木女牛=]", "remainder: 1"],
    [StemBranch, "label:[Fire-Tiger=,    *火男虎=]", "remainder: 2"],
    [StemBranch, "label:[Fire-Rabbit=,   *火女兎=]", "remainder: 3"],
    [StemBranch, "label:[Earth-Dragon=,  *土男龍=]", "remainder: 4"],
    [StemBranch, "label:[Earth-Snake=,   *土女蛇=]", "remainder: 5"],
    [StemBranch, "label:[Iron-Horse=,    *金男馬=]", "remainder: 6"],
    [StemBranch, "label:[Iron-Goat=,     *金女羊=]", "remainder: 7"],
    [StemBranch, "label:[Water-Monkey=,  *水男猴=]", "remainder: 8"],
    [StemBranch, "label:[Water-Rooster=, *水女鷄=]", "remainder: 9"],
    [StemBranch, "label:[Wood-Dog=,      *木男狗=]", "remainder:10"],
    [StemBranch, "label:[Wood-Pig=,      *木女猪=]", "remainder:11"],
    [StemBranch, "label:[Fire-Rat=,      *火男鼠=]", "remainder:12"],
    [StemBranch, "label:[Fire-Ox=,       *火女牛=]", "remainder:13"],
    [StemBranch, "label:[Earth-Tiger=,   *土男虎=]", "remainder:14"],
    [StemBranch, "label:[Earth-Rabbit=,  *土女兎=]", "remainder:15"],
    [StemBranch, "label:[Iron-Dragon=,   *金男龍=]", "remainder:16"],
    [StemBranch, "label:[Iron-Snake=,    *金女蛇=]", "remainder:17"],
    [StemBranch, "label:[Water-Horse=,   *水男馬=]", "remainder:18"],
    [StemBranch, "label:[Water-Goat=,    *水女羊=]", "remainder:19"],
    [StemBranch, "label:[Wood-Monkey=,   *木男猴=]", "remainder:20"],
    [StemBranch, "label:[Wood-Rooster=,  *木女鷄=]", "remainder:21"],
    [StemBranch, "label:[Fire-Dog=,      *火男狗=]", "remainder:22"],
    [StemBranch, "label:[Fire-Pig=,      *火女猪=]", "remainder:23"],
    [StemBranch, "label:[Earth-Rat=,     *土男鼠=]", "remainder:24"],
    [StemBranch, "label:[Earth-Ox=,      *土女牛=]", "remainder:25"],
    [StemBranch, "label:[Iron-Tiger=,    *金男虎=]", "remainder:26"],
    [StemBranch, "label:[Iron-Rabbit=,   *金女兎=]", "remainder:27"],
    [StemBranch, "label:[Water-Dragon=,  *水男龍=]", "remainder:28"],
    [StemBranch, "label:[Water-Snake=,   *水女蛇=]", "remainder:29"],
    [StemBranch, "label:[Wood-Horse=,    *木男馬=]", "remainder:30"],
    [StemBranch, "label:[Wood-Goat=,     *木女羊=]", "remainder:31"],
    [StemBranch, "label:[Fire-Monkey=,   *火男猴=]", "remainder:32"],
    [StemBranch, "label:[Fire-Rooster=,  *火女鷄=]", "remainder:33"],
    [StemBranch, "label:[Earth-Dog=,     *土男狗=]", "remainder:34"],
    [StemBranch, "label:[Earth-Pig=,     *土女猪=]", "remainder:35"],
    [StemBranch, "label:[Iron-Rat=,      *金男鼠=]", "remainder:36"],
    [StemBranch, "label:[Iron-Ox=,       *金女牛=]", "remainder:37"],
    [StemBranch, "label:[Water-Tiger=,   *水男虎=]", "remainder:38"],
    [StemBranch, "label:[Water-Rabbit=,  *水女兎=]", "remainder:39"],
    [StemBranch, "label:[Wood-Dragon=,   *木男龍=]", "remainder:40"],
    [StemBranch, "label:[Wood-Snake=,    *木女蛇=]", "remainder:41"],
    [StemBranch, "label:[Fire-Horse=,    *火男馬=]", "remainder:42"],
    [StemBranch, "label:[Fire-Goat=,     *火女羊=]", "remainder:43"],
    [StemBranch, "label:[Earth-Monkey=,  *土男猴=]", "remainder:44"],
    [StemBranch, "label:[Earth-Rooster=, *土女鷄=]", "remainder:45"],
    [StemBranch, "label:[Iron-Dog=,      *金男狗=]", "remainder:46"],
    [StemBranch, "label:[Iron-Pig=,      *金女猪=]", "remainder:47"],
    [StemBranch, "label:[Water-Rat=,     *水男鼠=]", "remainder:48"],
    [StemBranch, "label:[Water-Ox=,      *水女牛=]", "remainder:49"],
    [StemBranch, "label:[Wood-Tiger=,    *木男虎=]", "remainder:50"],
    [StemBranch, "label:[Wood-Rabbit=,   *木女兎=]", "remainder:51"],
    [StemBranch, "label:[Fire-Dragon=,   *火男龍=]", "remainder:52"],
    [StemBranch, "label:[Fire-Snake=,    *火女蛇=]", "remainder:53"],
    [StemBranch, "label:[Earth-Horse=,   *土男馬=]", "remainder:54"],
    [StemBranch, "label:[Earth-Goat=,    *土女羊=]", "remainder:55"],
    [StemBranch, "label:[Iron-Monkey=,   *金男猴=]", "remainder:56"],
    [StemBranch, "label:[Iron-Rooster=,  *金女鷄=]", "remainder:57"],
    [StemBranch, "label:[Water-Dog=,     *水男狗=]", "remainder:58"],
    [StemBranch, "label:[Water-Pig=,     *水女猪=]", "remainder:59"]
  ]
]]
Javanese =

Javanese Residues

[When::BasicTypes::M17n, [
   "namespace:[en=http://en.wikipedia.org/wiki/, ja=http://ja.wikipedia.org/wiki/]",
   "locale:[=en:, ja=ja:, alias]",
   "names:[Javanese]",

   [Residue,
     "label:[Windu=]", "divisor:8", "year:3",
     [Residue, "label:[Alip=   ]", "remainder:  0"],
     [Residue, "label:[Ehe=    ]", "remainder:  1"],
     [Residue, "label:[Jimawal=]", "remainder:  2"],
     [Residue, "label:[Je=     ]", "remainder:  3"],
     [Residue, "label:[Dal=    ]", "remainder:  4"],
     [Residue, "label:[Be=     ]", "remainder:  5"],
     [Residue, "label:[Wawu=   ]", "remainder:  6"],
     [Residue, "label:[Jimakir=]", "remainder:  7"]
   ],

   [Residue,
     "label:[Pasaran=, 五曜=]", "divisor:5", "day:1",
     [Residue, "label:[Paing=  ]", "remainder:  0"],
     [Residue, "label:[Pon=    ]", "remainder:  1"],
     [Residue, "label:[Wage=   ]", "remainder:  2"],
     [Residue, "label:[Kliwon= ]", "remainder:  3"],
     [Residue, "label:[Legi=   ]", "remainder:  4"]
   ],

   [Residue,
     "label:[Paringkelan=, 六曜=]", "divisor:6", "day:2",
     [Residue, "label:[Tungle=   ]", "remainder:  0"],
     [Residue, "label:[Aryang=   ]", "remainder:  1"],
     [Residue, "label:[Warukung= ]", "remainder:  2"],
     [Residue, "label:[Paningron=]", "remainder:  3"],
     [Residue, "label:[Uwas=     ]", "remainder:  4"],
     [Residue, "label:[Mawulu=   ]", "remainder:  5"]
   ],

   [Residue,
     "label:[Week=, 七曜=]", "divisor:7", "day:6",
     [Residue, "label:[Minggu=]", "remainder:  0"],
     [Residue, "label:[Senin= ]", "remainder:  1"],
     [Residue, "label:[Selasa=]", "remainder:  2"],
     [Residue, "label:[Rabu=  ]", "remainder:  3"],
     [Residue, "label:[Kamis= ]", "remainder:  4"],
     [Residue, "label:[Jumat= ]", "remainder:  5"],
     [Residue, "label:[Sabtu= ]", "remainder:  6"]
   ],

   [Residue,
     "label:[Wuku=]", "divisor:210", "day:146",
     [Residue, "label:[Sinto=       ]", "remainder:  0"],
     [Residue, "label:[Landep=      ]", "remainder:  7"],
     [Residue, "label:[Wukir=       ]", "remainder: 14"],
     [Residue, "label:[Kurantil=    ]", "remainder: 21"],
     [Residue, "label:[Tolu=        ]", "remainder: 28"],
     [Residue, "label:[Gumbrek=     ]", "remainder: 35"],
     [Residue, "label:[Warigalit=   ]", "remainder: 42"],
     [Residue, "label:[Warigagung=  ]", "remainder: 49"],
     [Residue, "label:[Julungwangi= ]", "remainder: 56"],
     [Residue, "label:[Sungsang=    ]", "remainder: 63"],
     [Residue, "label:[Galungan=    ]", "remainder: 70"],
     [Residue, "label:[Kuningan=    ]", "remainder: 77"],
     [Residue, "label:[Langkir=     ]", "remainder: 84"],
     [Residue, "label:[Mondosijo=   ]", "remainder: 91"],
     [Residue, "label:[Julungpujut= ]", "remainder: 98"],
     [Residue, "label:[Pahang=      ]", "remainder:105"],
     [Residue, "label:[Kuruwekut=   ]", "remainder:112"],
     [Residue, "label:[Marakeh=     ]", "remainder:119"],
     [Residue, "label:[Tambir=      ]", "remainder:126"],
     [Residue, "label:[Medangkungan=]", "remainder:133"],
     [Residue, "label:[Maktal=      ]", "remainder:140"],
     [Residue, "label:[Waye=        ]", "remainder:147"],
     [Residue, "label:[Menahil=     ]", "remainder:154"],
     [Residue, "label:[Prangbakat=  ]", "remainder:161"],
     [Residue, "label:[Bolo=        ]", "remainder:168"],
     [Residue, "label:[Wugu=        ]", "remainder:175"],
     [Residue, "label:[Wayang=      ]", "remainder:182"],
     [Residue, "label:[Kulawu=      ]", "remainder:189"],
     [Residue, "label:[Dukut=       ]", "remainder:196"],
     [Residue, "label:[Watugunung=  ]", "remainder:203"]
   ]
]]
DefaultDayIndex =

default index for day coordinate

Coordinates::Index.new
DefaultDateIndices =

default indices for date coordinates

[
  Coordinates::Index.new({:unit=>12}),
  DefaultDayIndex
]
DefaultTimeIndices =

default indices for time coordinates

[
  Coordinates::Index.new({:base=>0, :unit=>24}),
  Coordinates::Index.new({:base=>0, :unit=>60}),
  Coordinates::Index.new({:base=>0, :unit=>60})
]

Class Method Summary collapse

Class Method Details

.to_deg(src, dir) ⇒ Numeric

60進->10進変換

Parameters:

  • src (String)

    60進法で表した方向付きの数値

  • dir (String)

    方向 ('NS' または 'EW')

Returns:

  • (Numeric)

    10進変換した数値 (src が nil なら0.0を、Numeric ならそのままsrcを返す)


32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/when_exe/coordinates.rb', line 32

def self.to_deg(src, dir)
  case src
  when String
    src = src.gsub(/_+/,'').gsub(/@/, '.')
    return src.to_f unless (src =~ MATCH[dir])
    sign  = ($1 == dir[1..1]) ? -1 : +1
    value = src.gsub(MATCH[dir], '').strip
    if ((value + "00000") =~ /^(\d+)\.(\d{2})(\d{2})(\d+)$/)
      deg, min, sec, frac = $~[1..4]
      sec += "." + frac
    else
      deg, min, sec = value.split(/[^\d.]+/)
    end
    return sign * (deg.to_i + (min||0).to_f/60 +  (sec||0).to_f/3600)
  when NilClass
    0.0
  when Numeric
    src
  else
    raise TypeError, "Invalid Location Type"
  end
end

.to_dms(src, dir) ⇒ String

10進->60進変換

Parameters:

  • src (Numeric)

    数値

  • dir (String)

    方向 ('NS' または 'EW')

Returns:

  • (String)

    60進変換した数値


62
63
64
65
66
67
68
# File 'lib/when_exe/coordinates.rb', line 62

def self.to_dms(src, dir)
  dir      = (src >= 0) ? dir[0..0] : dir[1..1]
  deg, min  =  src.abs.divmod(1)
  min, sec  = (60*min).divmod(1)
  sec       = (60*sec).floor
  (['N','S'].include?(dir) ? "%02d.%02d%02d%s" : "%03d.%02d%02d%s") % [deg, min, sec, dir]
end