index.php 52 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494
  1. <?php
  2. //require '../../app/checklogin.inc';
  3. require '../public/config.php';
  4. require_once '../public/load_lang.php';
  5. if(isset($_GET["language"])){
  6. $currLanguage=$_GET["language"];
  7. $_COOKIE["language"]=$currLanguage;
  8. }
  9. else{
  10. if(isset($_COOKIE["language"])){
  11. $currLanguage=$_COOKIE["language"];
  12. }
  13. else{
  14. $currLanguage="en";
  15. $_COOKIE["language"]=$currLanguage;
  16. }
  17. }
  18. //load language file
  19. /*
  20. if(file_exists($dir_language.$currLanguage.".php")){
  21. require $dir_language.$currLanguage.".php";
  22. }
  23. else{
  24. require $dir_language."default.php";
  25. }
  26. require __DIR__."/../../app/language/default.php";
  27. */
  28. if(isset($_GET["device"])){
  29. $currDevice=$_GET["device"];
  30. }
  31. else{
  32. if(isset($_COOKIE["device"])){
  33. $currDevice=$_COOKIE["device"];
  34. }
  35. else{
  36. $currDevice="computer";
  37. }
  38. }
  39. //修改页面编码
  40. //header("content-type:text/html;charset=utf-8");
  41. //获取当前年
  42. $year=$_GET['y']?$_GET['y']:date('Y');
  43. //获取当年月
  44. $month=$_GET['m']?$_GET['m']:date('m');
  45. //获取当前日
  46. //$selected_date=$_GET['d']?$_GET['d']:date('j');
  47. $dir_app="../studio/";
  48. ?>
  49. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  50. <html>
  51. <head>
  52. <script language="javascript" src="../studio/charcode/sinhala.js"></script>
  53. <script language="javascript" src="../studio/charcode/myanmar.js"></script>
  54. <script language="javascript" src="../studio/charcode/unicode.js"></script>
  55. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
  56. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  57. <link type="text/css" rel="stylesheet" href="<?php echo $dir_app; ?>css/style.css"/>
  58. <link type="text/css" rel="stylesheet" href="<?php echo $dir_app; ?>css/color_day.css" id="colorchange" />
  59. <link type="text/css" rel="stylesheet" href="<?php echo $dir_app; ?>css/style.css"/>
  60. <title><?php echo $_local->gui->pcd_studio;?></title>
  61. <script src="<?php echo $dir_app; ?>js/jquery-3.3.1.min.js"></script>
  62. <!-- <script language="javascript" src="<?php echo $dir_app; ?>charcode/sinhala.js"></script>
  63. <script language="javascript" src="<?php echo $dir_app; ?>charcode/myanmar.js"></script>
  64. <script language="javascript" src="<?php echo $dir_app; ?>charcode/unicode.js"></script>
  65. -->
  66. <script>
  67. <?php
  68. //加载js语言包
  69. require_once '../public/load_lang_js.php';
  70. ?>
  71. </script>
  72. <style type="text/css">
  73. .BE_icon_span{
  74. width: 7em;
  75. display: inline-block;
  76. }
  77. #BE_icon{
  78. font-size: 100%;
  79. }
  80. .td_today{
  81. margin: auto;
  82. background: silver;
  83. color: black;
  84. width: 2em;
  85. }
  86. .new_moon_uposatha{
  87. background:black;
  88. border-radius: 2em;
  89. width: 2em;
  90. margin: auto;
  91. }
  92. .full_moon_uposatha{
  93. background:orange;
  94. border-radius: 2em;
  95. width: 2em;
  96. margin: auto;
  97. }
  98. .table_body{
  99. width:700px;
  100. border:1px;
  101. font-size: 60%;
  102. width: 95%;
  103. max-width: 45em;
  104. line-height: 2em;
  105. text-align: center;
  106. margin: 20px 0px;
  107. border-collapse: collapse;
  108. }
  109. .table_line{
  110. display: flex;
  111. }
  112. .table_column{
  113. border:solid;
  114. border-width: thin;
  115. flex:1;
  116. }
  117. input[type="number"]{
  118. width: 3em;
  119. }
  120. input[type="date"]{
  121. width: 10em;
  122. }
  123. </style>
  124. <script type="text/javascript">
  125. var g_device = "computer";
  126. var strSertch = location.search;
  127. if(strSertch.length>0){
  128. strSertch = strSertch.substr(1);
  129. var sertchList=strSertch.split('&');
  130. for ( i in sertchList){
  131. var item = sertchList[i].split('=');
  132. if(item[0]=="device"){
  133. g_device=item[1];
  134. }
  135. }
  136. }
  137. if(g_device=="mobile"){
  138. g_is_mobile=true;
  139. }
  140. else{
  141. g_is_mobile=false;
  142. }
  143. var g_language="en";
  144. function setCookie(c_name,value,expiredays)
  145. {
  146. var exdate=new Date()
  147. exdate.setDate(exdate.getDate()+expiredays)
  148. document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : "; expires="+exdate.toGMTString())
  149. }
  150. var pali_num_str=[
  151. { "id":"1" , "value":"eka" },
  152. { "id":"2" , "value":"dve" },
  153. { "id":"3" , "value":"ti" },
  154. { "id":"4" , "value":"catu" },
  155. { "id":"5" , "value":"pañca" },
  156. { "id":"6" , "value":"cha" },
  157. { "id":"7" , "value":"satta" },
  158. { "id":"8" , "value":"aṭṭha" },
  159. { "id":"9" , "value":"nava" },
  160. { "id":"10" , "value":"dasa" },
  161. { "id":"11" , "value":"ekādasa" },
  162. { "id":"12" , "value":"dvādasa " },
  163. { "id":"13" , "value":"terasa" },
  164. { "id":"14" , "value":"cuddasa" },
  165. { "id":"15" , "value":"paṇṇarasa" },
  166. { "id":"16" , "value":"soḷasa" },
  167. { "id":"17" , "value":"sattarasa" },
  168. { "id":"18" , "value":"aṭṭharasa" },
  169. { "id":"19" , "value":"ekūna-vīsati" },
  170. { "id":"20" , "value":"vīsati" },
  171. { "id":"21" , "value":"eka-vīsati" },
  172. { "id":"22" , "value":"dve-vīsati" },
  173. { "id":"23" , "value":"te-vīsati" },
  174. { "id":"24" , "value":"catu-vīsati" },
  175. { "id":"25" , "value":"pañca-vīsati" },
  176. { "id":"26" , "value":"cha-bbīsati" },
  177. { "id":"27" , "value":"satta-vīsati" },
  178. { "id":"28" , "value":"aṭṭha-vīsati" },
  179. { "id":"29" , "value":"ekūna-tiṃsati" },
  180. { "id":"30" , "value":"tiṃsati" },
  181. { "id":"31" , "value":"eka-tiṃsati" },
  182. { "id":"32" , "value":"dvattiṃsati" },
  183. { "id":"33" , "value":"tettiṃsati" },
  184. { "id":"34" , "value":"catuttiṃsati" },
  185. { "id":"35" , "value":"pañcatiṃsati" },
  186. { "id":"36" , "value":"chattiṃsati" },
  187. { "id":"37" , "value":"sattatiṃsati" },
  188. { "id":"38" , "value":"aṭṭhatiṃsati" },
  189. { "id":"39" , "value":"ekūna-cattālīsati" },
  190. { "id":"40" , "value":"cattālīsati" },
  191. { "id":"41" , "value":"eka-cattālīsati" },
  192. { "id":"42" , "value":"dve-cattālīsati" },
  193. { "id":"43" , "value":"ti-cattālīsati" },
  194. { "id":"44" , "value":"catu-cattālīsati" },
  195. { "id":"45" , "value":"pañca-cattālīsati" },
  196. { "id":"46" , "value":"cha-cattālīsati" },
  197. { "id":"47" , "value":"satta-cattālīsati" },
  198. { "id":"48" , "value":"aṭṭha-cattālīsati" },
  199. { "id":"49" , "value":"ekūna-paññāsā" },
  200. { "id":"50" , "value":"paññāsā" },
  201. { "id":"51" , "value":"eka-paññāsā" },
  202. { "id":"52" , "value":"dve-paññāsā" },
  203. { "id":"53" , "value":"ti-paññāsā" },
  204. { "id":"54" , "value":"catu-paññāsā" },
  205. { "id":"55" , "value":"pañca-paññāsā" },
  206. { "id":"56" , "value":"cha-paññāsā" },
  207. { "id":"57" , "value":"satta-paññāsā" },
  208. { "id":"58" , "value":"aṭṭha-paññāsā" },
  209. { "id":"59" , "value":"ekūna-saṭṭhi" },
  210. { "id":"60" , "value":"saṭṭhi" },
  211. { "id":"61" , "value":"eka-saṭṭhi" },
  212. { "id":"62" , "value":"dve-saṭṭhi" },
  213. { "id":"63" , "value":"ti-saṭṭhi" },
  214. { "id":"64" , "value":"catu-saṭṭhi" },
  215. { "id":"65" , "value":"pañca-saṭṭhi" },
  216. { "id":"66" , "value":"cha-saṭṭhi" },
  217. { "id":"67" , "value":"satta-saṭṭhi" },
  218. { "id":"68" , "value":"aṭṭha-saṭṭhi" },
  219. { "id":"69" , "value":"ekūna-sattati" },
  220. { "id":"70" , "value":"sattati" },
  221. { "id":"71" , "value":"eka-sattati" },
  222. { "id":"72" , "value":"dve-sattati" },
  223. { "id":"73" , "value":"ti-sattati" },
  224. { "id":"74" , "value":"catu-sattati" },
  225. { "id":"75" , "value":"pañca-sattati" },
  226. { "id":"76" , "value":"cha-sattati" },
  227. { "id":"77" , "value":"satta-sattati" },
  228. { "id":"78" , "value":"aṭṭha-sattati" },
  229. { "id":"79" , "value":"ekūnāsīti" },
  230. { "id":"80" , "value":"asīti" },
  231. { "id":"81" , "value":"eka-asīti" },
  232. { "id":"82" , "value":"dve-asīti" },
  233. { "id":"83" , "value":"ti-asīti" },
  234. { "id":"84" , "value":"catu-asīti" },
  235. { "id":"85" , "value":"pañca-asīti" },
  236. { "id":"86" , "value":"cha-asīti" },
  237. { "id":"87" , "value":"satta-asīti" },
  238. { "id":"88" , "value":"aṭṭha-asīti" },
  239. { "id":"89" , "value":"ekūna-navuti" },
  240. { "id":"90" , "value":"navuti" },
  241. { "id":"91" , "value":"eka-navuti" },
  242. { "id":"92" , "value":"dve-navuti" },
  243. { "id":"93" , "value":"ti-navuti" },
  244. { "id":"94" , "value":"catu-navuti" },
  245. { "id":"95" , "value":"pañca-navuti" },
  246. { "id":"96" , "value":"cha-navuti" },
  247. { "id":"97" , "value":"satta-navuti" },
  248. { "id":"98" , "value":"aṭṭha-navuti" },
  249. { "id":"99" , "value":"ekūna-sata" },
  250. { "id":"100" , "value":"sata" },
  251. { "id":"200" , "value":"dvi-sata" },
  252. { "id":"300" , "value":"ti-sata" },
  253. { "id":"400" , "value":"catu-sata" },
  254. { "id":"500" , "value":"pañca-sata" },
  255. { "id":"600" , "value":"cha-sata" },
  256. { "id":"700" , "value":"satta-sata" },
  257. { "id":"800" , "value":"aṭṭha-sata" },
  258. { "id":"900" , "value":"nava-sata" },
  259. { "id":"1000" , "value":"sahassa" },
  260. { "id":"2000" , "value":"dve-sahassa" },
  261. { "id":"3000" , "value":"ti-sahassa" },
  262. { "id":"4000" , "value":"catu-sahassa" },
  263. { "id":"5000" , "value":"pañca-sahassa" }
  264. ]
  265. var pali_num_str_pl=[
  266. //{ "id":"0" , "value":"na" },
  267. //{ "id":"1" , "value":"eka" },
  268. { "id":"2" , "value":"dve" },
  269. { "id":"3" , "value":"tīṇi" },
  270. { "id":"4" , "value":"cattāri" },
  271. { "id":"5" , "value":"pañca" },
  272. { "id":"6" , "value":"cha" },
  273. { "id":"7" , "value":"satta" },
  274. { "id":"8" , "value":"aṭṭha" },
  275. { "id":"9" , "value":"nava" },
  276. { "id":"10" , "value":"dasa" },
  277. { "id":"11" , "value":"ekādasa" },
  278. { "id":"12" , "value":"dvādasa " },
  279. { "id":"13" , "value":"terasa" },
  280. { "id":"14" , "value":"cuddasa" },
  281. { "id":"15" , "value":"paṇṇarasa" },
  282. { "id":"16" , "value":"soḷasa" },
  283. { "id":"17" , "value":"sattarasa" },
  284. { "id":"18" , "value":"aṭṭharasa" },
  285. { "id":"19" , "value":"ekūna-vīsati" },
  286. { "id":"20" , "value":"vīsati" },
  287. { "id":"21" , "value":"eka-vīsati" },
  288. { "id":"22" , "value":"dve-vīsati" },
  289. { "id":"23" , "value":"te-vīsati" },
  290. { "id":"24" , "value":"catu-vīsati" },
  291. { "id":"25" , "value":"pañca-vīsati" },
  292. { "id":"26" , "value":"cha-bbīsati" },
  293. { "id":"27" , "value":"satta-vīsati" },
  294. { "id":"28" , "value":"aṭṭha-vīsati" },
  295. { "id":"29" , "value":"ekūna-tiṃsati" }
  296. ]
  297. var pali_year_name=[
  298. { "id":"0" , "value":"sappa" , "icon":"🐍"},
  299. //🐀🐃🐄🐏🐑
  300. //🐭🐮🐯🐰🐲🐍🐴🐵🐔🐶🐷
  301. { "id":"1" , "value":"assa" , "icon":"🐎"},
  302. { "id":"2" , "value":"aja" , "icon":"🐐"},
  303. { "id":"3" , "value":"kapi" , "icon":"🐒"},
  304. { "id":"4" , "value":"kukkuṭa" , "icon":"🐓"},
  305. { "id":"5" , "value":"soṇa" , "icon":"🐕"},
  306. { "id":"6" , "value":"sūkara" , "icon":"🐖"},
  307. { "id":"7" , "value":"mūsika" , "icon":"🐁"},
  308. { "id":"8" , "value":"vasabha" , "icon":"🐂"},
  309. { "id":"9" , "value":"vyaggaha" , "icon":"🐅"},
  310. { "id":"10" , "value":"sasa" , "icon":"🐇"},
  311. { "id":"11" , "value":"nāga" , "icon":"🐉"}
  312. ]
  313. var pali_month_name=[
  314. { "id":"1" , "value":"jeṭṭha" , "season":"gimhāna" , "season_icon":"☀"},//5.X-四-十五-心
  315. { "id":"2" , "value":"asāḷha" , "season":"gimhāna" , "season_icon":"☀"},//6.X-五-十五、十六-箕、斗
  316. { "id":"3" , "value":"sāvana" , "season":"vassāna" , "season_icon":"☔"},//7.X-六-十五-女
  317. { "id":"4" , "value":"poṭṭhapāda" , "season":"vassāna" , "season_icon":"☔"},//8.x-七-十五、十六-室、壁
  318. { "id":"5" , "value":"assajuja" , "season":"vassāna" , "season_icon":"☔"},//9.X-八-十五-樓
  319. { "id":"6" , "value":"kattika" , "season":"vassāna" , "season_icon":"☔"},//10.X-九-十五-昂
  320. { "id":"7" , "value":"māgasira" , "season":"hemanta" , "season_icon":"❄"},//11.X-十-十五-觜
  321. { "id":"8" , "value":"phussa" , "season":"hemanta" , "season_icon":"❄"},//12.X-十一-十五-鬼
  322. { "id":"9" , "value":"māgha" , "season":"hemanta" , "season_icon":"❄"},//1.X-十二-十五-星
  323. { "id":"10" , "value":"phagguna" , "season":"hemanta" , "season_icon":"❄"},//2.X-正月-十四、十五-張、異
  324. { "id":"11" , "value":"citta" , "season":"gimhāna" , "season_icon":"☀"},//3.X-二月-十五-角
  325. { "id":"12" , "value":"vesākha" , "season":"gimhāna" , "season_icon":"☀"}//4.X-三月-十五-氐
  326. ]
  327. var pali_date_name=[
  328. { "id":"1" , "value":"paṭhamaṃ" },
  329. { "id":"2" , "value":"dutiyaṃ" },
  330. { "id":"3" , "value":"tatiyaṃ" },
  331. { "id":"4" , "value":"catutthaṃ" },
  332. { "id":"5" , "value":"pañcamaṃ" },
  333. { "id":"6" , "value":"chaṭṭhamaṃ" },
  334. { "id":"7" , "value":"sattamaṃ" },
  335. { "id":"8" , "value":"aṭṭhamaṃ" },
  336. { "id":"9" , "value":"navamaṃ" },
  337. { "id":"10" , "value":"dasamaṃ" },
  338. { "id":"11" , "value":"ekādasamaṃ" },
  339. { "id":"12" , "value":"dvādasamaṃ" },
  340. { "id":"13" , "value":"terasamaṃ" },
  341. { "id":"14" , "value":"cuddasamaṃ" },
  342. { "id":"15" , "value":"paṇṇarasamaṃ" }
  343. ]
  344. var pali_week_day_name=[
  345. { "id":"0" , "value":"ravi" ,"icon":"☀"},
  346. { "id":"1" , "value":"canda" ,"icon":"🌙"},
  347. { "id":"2" , "value":"bhumma" ,"icon":""},//土
  348. { "id":"3" , "value":"budha" ,"icon":""},//水星
  349. { "id":"4" , "value":"guru" ,"icon":""},//木星
  350. { "id":"5" , "value":"sukka" ,"icon":"♀"},//金星
  351. { "id":"6" , "value":"sora" ,"icon":"♂"}//火星
  352. ]
  353. var g_Unix_now=0;
  354. function startTime(){
  355. var today=new Date()
  356. var h=today.getHours()
  357. var m=today.getMinutes()
  358. var s=today.getSeconds()
  359. // add a zero in front of numbers<10
  360. h=checkTime(h)
  361. m=checkTime(m)
  362. s=checkTime(s)
  363. document.getElementById('clock_string').innerHTML=h+":"+m+":"+s
  364. g_Unix_now=today.getTime()
  365. t=setTimeout('startTime()',500)
  366. }
  367. function checkTime(i){
  368. if (i<10)
  369. {i="0" + i}
  370. return i
  371. }
  372. </script>
  373. </head>
  374. <body class="indexbody" onload="startTime()">
  375. <!-- tool bar begin-->
  376. <div class='index_toolbar'>
  377. <div class="toolgroup1">
  378. <span><?php echo $_local->gui->language_select;?></span>
  379. <?php
  380. echo "<select id='id_language' name='menu' onchange=\"menuLangrage(this,".$year.",".$month.")\">";
  381. echo "<option value='pali' >Pāḷi Roman</option>";
  382. echo "<option value='en' >English</option>";
  383. echo "<option value='si' >සිංහල</option>";
  384. echo "<option value='my' >myanmar</option>";
  385. echo "<option value='zh-cn' >简体中文</option>";
  386. echo "<option value='zh-tw' >繁體中文</option>";
  387. echo "</select>";
  388. ?>
  389. </div>
  390. </div>
  391. <!--tool bar end -->
  392. <script>
  393. document.getElementById("id_language").value="<?php echo($currLanguage); ?>";
  394. </script>
  395. <?php
  396. //獲取今天是幾號
  397. $cur_date=date('j');
  398. //获取当前月多少天
  399. $days=date('t',strtotime("{$year}-{$month}-1"));
  400. //選定日
  401. if($cur_date>$days){
  402. $selected_date=1;
  403. }
  404. else{
  405. $selected_date=$cur_date;
  406. }
  407. //当前一号周几
  408. $week=date('w',strtotime("{$year}-{$month}-1"));
  409. //居中
  410. echo "<br/><br/><br/>";
  411. echo "<div style='display:flex; flex-direction: column;'>";
  412. echo "<center style='display: flex;flex: 3;flex-direction: column;padding: 10px;'>";
  413. //設定vesakha日
  414. $vesakha_day=date_create("2019-5-18");
  415. $vesakha_day_1=date_sub($vesakha_day,date_interval_create_from_date_string("-354 days"));
  416. $vesakha_day=date_create("2019-5-18");
  417. //當前日差值
  418. $diff=date_diff($vesakha_day,date_create("{$year}-{$month}-{$selected_date}"));
  419. $diff_1=date_diff($vesakha_day_1,date_create("{$year}-{$month}-{$selected_date}"));
  420. $days_diff=$diff->format("%R%a");
  421. $days_diff_1=$diff_1->format("%R%a");
  422. if($days_diff_1>0){
  423. $days_diff=$days_diff_1;
  424. }
  425. //當前年差值
  426. if($diff->format("%R")=="+" && $diff_1->format("%R")=="+"){
  427. $years_diff_total=544-1+date_format($vesakha_day_1,"Y");
  428. }
  429. else if($diff->format("%R")=="+" && $diff_1->format("%R")=="-"){
  430. $years_diff_total=544-1+date_format($vesakha_day,"Y");
  431. }
  432. else{
  433. $years_diff_total=544-2+date_format($vesakha_day,"Y");
  434. }
  435. //计算上个月
  436. if($month==1){
  437. $prevyear=$year-1;
  438. $prevmonth=12;
  439. }
  440. else{
  441. $prevyear=$year;
  442. $prevmonth=$month-1;
  443. }
  444. //计算下个月
  445. if($month==12){
  446. $nextyear=$year+1;
  447. $nextmonth=1;
  448. }
  449. else{
  450. $nextyear=$year;
  451. $nextmonth=$month+1;
  452. }
  453. //生成年份名稱
  454. if($currLanguage=="en"){
  455. $year_text=$year."/";
  456. }
  457. else{
  458. $year_text="{$year}".$_local->gui->saṃvacchara;//年
  459. }
  460. //生成月份名稱
  461. if($currLanguage=="en"){
  462. $month_text=date('F',strtotime("{$year}-{$month}-1"));
  463. }
  464. else{
  465. $month_text="{$month}".$_local->gui->māsa;//月
  466. }
  467. //输出表头
  468. echo "<h2 style='font-size: 80%;'>";
  469. echo "<a href='index.php?y={$prevyear}&m={$prevmonth}'>";
  470. echo $_local->gui->pubba_māsa;//上一月
  471. echo "</a>|";
  472. echo $year_text;
  473. echo $month_text;
  474. echo "|<a href='index.php?y={$nextyear}&m={$nextmonth}'>";
  475. echo $_local->gui->pacchā_māsa;//下一月
  476. echo "</a></h2>";
  477. //输出日期表格
  478. echo "<table class='table_body' >";
  479. echo "<tr class='table_line'>";
  480. echo "<th class='table_column'>".$_local->gui->ravi."</th>";
  481. echo "<th class='table_column'>".$_local->gui->canda."</th>";
  482. echo "<th class='table_column'>".$_local->gui->bhumma."</th>";
  483. echo "<th class='table_column'>".$_local->gui->budha."</th>";
  484. echo "<th class='table_column'>".$_local->gui->guru."</th>";
  485. echo "<th class='table_column'>".$_local->gui->sukka."</th>";
  486. echo "<th class='table_column'>".$_local->gui->sora."</th>";
  487. echo "</tr>";
  488. //铺表格
  489. for($i=1-$week; $i <=$days ;){
  490. echo "<tr class='table_line'>";
  491. for ($j=0; $j < 7; $j++){
  492. if ($i>$days || $i<1){
  493. echo "<td class='table_column'>&nbsp;</td>";
  494. }
  495. else if($i==$cur_date && $month==date('m')){
  496. $days_diff_X=$days_diff-$selected_date+$i;
  497. $cur_years_diff_total=$years_diff_total;
  498. $cur_days_diff=$days_diff_X;
  499. $cur_week_day=$j;
  500. echo "<td class='table_column' id='td_{$i}' onclick=\"pali_date($i,$days,$years_diff_total,$days_diff_X,$j,'".$currLanguage."',g_coordinate_this)\")' ><div class='td_today'>{$i}</div>";
  501. echo "</td>";
  502. if($i==$days){
  503. $key_days_num=$days_diff_X;
  504. }
  505. }
  506. else if($i==$selected_date){
  507. $days_diff_X=$days_diff-$selected_date+$i;
  508. $cur_years_diff_total=$years_diff_total;
  509. $cur_days_diff=$days_diff_X;
  510. $cur_week_day=$j;
  511. echo "<td class='table_column' id='td_{$i}' onclick=\"pali_date($i,$days,$years_diff_total,$days_diff,$j,'".$currLanguage."',g_coordinate_this)\">{$i}</td>";
  512. if($i==$days){
  513. $key_days_num=$days_diff;
  514. }
  515. }
  516. else{
  517. $days_diff_X=$days_diff-$selected_date+$i;
  518. $cur_years_diff_total=$years_diff_total;
  519. $cur_days_diff=$days_diff_X;
  520. $cur_week_day=$j;
  521. echo "<td class='table_column' id='td_{$i}' onclick=\"pali_date($i,$days,$years_diff_total,$days_diff_X,$j,'".$currLanguage."',g_coordinate_this)\">{$i}</td>";
  522. if($i==$days){
  523. $key_days_num=$days_diff_X;
  524. }
  525. }
  526. $i++;
  527. }
  528. echo "</tr>";
  529. }
  530. echo "</table>";
  531. echo "<div id='position_change'>";
  532. echo "<span id='selected_position_string'>".$_local->gui->loading."</span>";
  533. echo "<button onclick='getLocation()' style='font-size: 100%; padding: 2px 6px;'>";
  534. echo "<svg class='icon' style='min-width: 1.8em; min-height: 1.8em;' >";
  535. echo "<path d='M12 8c-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4-1.79-4-4-4zm8.94 3A8.994 8.994 0 0 0 13 3.06V1h-2v2.06A8.994 8.994 0 0 0 3.06 11H1v2h2.06A8.994 8.994 0 0 0 11 20.94V23h2v-2.06A8.994 8.994 0 0 0 20.94 13H23v-2h-2.06zM12 19c-3.87 0-7-3.13-7-7s3.13-7 7-7 7 3.13 7 7-3.13 7-7 7z'/>";
  536. echo "</svg>".$_local->gui->my_loc."</button>";//自动定位
  537. echo "<button onclick='set_display(\"position_change\",\"position_input\")' style='display: none;'>".$_local->gui->change_position."</button>";//變更地點
  538. echo "</div>";
  539. echo "<div id='position_input' style='display:none;'><span>";
  540. echo $_local->gui->atitude;//緯度
  541. echo ":<input id='AT_selected_°' type='number' min='0' max='90' /> ° ";
  542. echo "<input id='AT_selected_’' type='number' min='0' max='60' /> ’ ";
  543. echo "<input id='AT_selected_”' type='number' min='0' max='60' /> ” ";
  544. echo "<select id='selected_NS'>";
  545. echo "<option value='+' >N</option>";
  546. echo "<option value='-' >S</option>";
  547. echo "</select>";
  548. echo "</span><span>";
  549. echo $_local->gui->longitude;//經度
  550. echo ":<input id='LT_selected_°' type='number' min='0' max='180' /> ° ";
  551. echo "<input id='LT_selected_’' type='number' min='0' max='60' /> ’ ";
  552. echo "<input id='LT_selected_”' type='number' min='0' max='60' /> ” ";
  553. echo "<select id='selected_WE'>";
  554. echo "<option value='+' >E</option>";
  555. echo "<option value='-' >W</option>";
  556. echo "</select>";
  557. echo "</span>";
  558. echo "<div id='position_selected'>";
  559. echo "</div>";
  560. echo "<div><button onclick='confirm()'>";
  561. echo $_local->gui->confirm;//確認
  562. echo "</button></div>";
  563. echo "</div>";
  564. echo "<div style='display:flex; margin: 20px;'>";
  565. echo "<div style='display:grid; flex:3'>";
  566. echo "<span id='time_A_string_X' style='font-size: 100%;'></span>";
  567. echo "<span id='clock_string_X' style='font-size: 100%;'></span>";
  568. echo "<span id='time_B_string_X' style='font-size: 100%; '></span>";
  569. echo "</div>";
  570. echo "<div id='time_sting_div' style='display:grid; flex:2'>";
  571. echo "<span id='time_A_string' style='font-size: 100%; '></span>";
  572. echo "<span id='clock_string' style='font-size: 100%; '></span>";
  573. echo "<span id='time_B_string' style='font-size: 100%; '></span>";
  574. echo "</div>";
  575. echo "<div style='display:grid; flex:6'>";
  576. echo "<span id='kala_judge' style='font-size: 100%; '></span>";
  577. echo "<span id='kala_inst_1' style='font-size: 100%; '></span>";
  578. echo "<span id='kala_inst_2' style='font-size: 100%; '></span>";
  579. echo "</div>";
  580. echo "</div>";
  581. echo "<div id='hori_ref' style='font-size: 100%; '></div>";
  582. //飛機過午問題
  583. echo "<div style='display:flex; font-size: 100%;'>";
  584. //起飛
  585. echo "<div style='flex:3;'>";
  586. echo "<div id='departure_position_result'>";
  587. echo "<span id='departure_position_string'></span>";
  588. echo "<button onclick='set_display(\"departure_position_result\",\"departure_position_input\")'>";
  589. echo $_local->gui->departure_in_detail;//起飛詳情
  590. echo "</button>";
  591. echo "</div>";
  592. echo "<div id='departure_position_input' style='display:none;'>";
  593. //起飛時間
  594. echo $_local->gui->date;//日期
  595. echo ":<input id='departure_date' type='date' />";
  596. echo $_local->gui->time;//時間
  597. echo ":<input id='departure_time' type='time' /><br>";
  598. //起飛地點
  599. echo "<span>";
  600. echo $_local->gui->atitude;//緯度
  601. echo ":<input id='AT_departure_°' type='number' min='0' max='90' /> ° ";
  602. echo "<input id='AT_departure_’' type='number' min='0' max='60' /> ’ ";
  603. echo "<input id='AT_departure_”' type='number' min='0' max='60' /> ” ";
  604. echo "<select id='departure_NS'>";
  605. echo "<option value='+' >N</option>";
  606. echo "<option value='-' >S</option>";
  607. echo "</select>";
  608. echo "</span><br><span>";
  609. echo $_local->gui->longitude;//經度
  610. echo ":<input id='LT_departure_°' type='number' min='0' max='180' /> ° ";
  611. echo "<input id='LT_departure_’' type='number' min='0' max='60' /> ’ ";
  612. echo "<input id='LT_departure_”' type='number' min='0' max='60' /> ” ";
  613. echo "<select id='departure_WE'>";
  614. echo "<option value='+' >E</option>";
  615. echo "<option value='-' >W</option>";
  616. echo "</select>";
  617. echo "</span>";
  618. echo "<div><button onclick='air_confirm(\"departure\")'>";
  619. echo $_local->gui->confirm;//確認
  620. echo "</button></div></div></div>";
  621. //降落
  622. echo "<div style='flex:3;'>";
  623. echo "<div id='arrival_position_result'>";
  624. echo "<span id='arrival_position_string'></span>";
  625. echo "<button onclick='set_display(\"arrival_position_result\",\"arrival_position_input\")'>";
  626. echo $_local->gui->arrival_in_detail;//降落詳情
  627. echo "</button>";
  628. echo "</div>";
  629. echo "<div id='arrival_position_input' style='display:none;'>";
  630. //降落時間
  631. echo $_local->gui->date;//日期
  632. echo ":<input id='arrival_date' type='date' />";
  633. echo $_local->gui->time;//時間
  634. echo ":<input id='arrival_time' type='time' /><br>";
  635. //降落地點
  636. echo "<span>";
  637. echo $_local->gui->atitude;//緯度
  638. echo ":<input id='AT_arrival_°' type='number' min='0' max='90' /> ° ";
  639. echo "<input id='AT_arrival_’' type='number' min='0' max='60' /> ’ ";
  640. echo "<input id='AT_arrival_”' type='number' min='0' max='60' /> ” ";
  641. echo "<select id='arrival_NS'>";
  642. echo "<option value='+' >N</option>";
  643. echo "<option value='-' >S</option>";
  644. echo "</select>";
  645. echo "</span><br><span>";
  646. echo $_local->gui->longitude;//經度
  647. echo ":<input id='LT_arrival_°' type='number' min='0' max='180' /> ° ";
  648. echo "<input id='LT_arrival_’' type='number' min='0' max='60' /> ’ ";
  649. echo "<input id='LT_arrival_”' type='number' min='0' max='60' /> ” ";
  650. echo "<select id='arrival_WE'>";
  651. echo "<option value='+' >E</option>";
  652. echo "<option value='-' >W</option>";
  653. echo "</select>";
  654. echo "</span>";
  655. echo "<div><button onclick='air_confirm(\"arrival\")'>";
  656. echo $_local->gui->confirm;//確認
  657. echo "</button></div></div></div>";
  658. echo "</div>";
  659. echo "<span id='key_num_string' style='display: none; '>{$key_days_num}-{$days}-{$year}-{$month}</span>";
  660. if($cur_years_diff_total!=null && $cur_days_diff!=null && $cur_week_day!=null){
  661. echo "<span id='cur_day_string' style='display: none; '>{$cur_date}-{$days}-{$cur_years_diff_total}-{$cur_days_diff}-{$cur_week_day}-{$currLanguage}</span>";
  662. }
  663. echo "</center>";
  664. /*date_default_timezone_set("Asia/Rangoon");
  665. $Unix_now_time=strtotime("now");
  666. $sun_info=date_sun_info(strtotime("now"),7.738562,80.519675);
  667. $sun_info_1=date_sun_info(strtotime("+1 day"),7.738562,80.519675);
  668. $Unix_dawn=$sun_info['civil_twilight_begin']*1000;
  669. $Unix_dawn_1=$sun_info_1['civil_twilight_begin']*1000;
  670. $Unix_noon=($sun_info['sunrise']+$sun_info['sunset'])/2*1000;
  671. $Unix_noon_1=($sun_info_1['sunrise']+$sun_info_1['sunset'])/2*1000;*/
  672. echo "<span id='time_string' style='display: none;'></span>";//
  673. echo "<span id='air_time_string' style='display: none;'></span>";//
  674. //echo date("H:i:s",$Unix_dawn)."<br/>";
  675. //echo date("H:i:s",$Unix_noon)."<br/>";
  676. echo "<div id='sun_AT' style='display:none;'>{$month}-{$selected_date}</div>";
  677. //echo "<button onclick='set_uposatha_day()'>set uposatha</button>";
  678. echo "<div id='pali_era' style='font-size: 150%;display: flex;flex: 7;padding: 10px;flex-direction: column;'>";
  679. echo "<div id='pali_era_graph' style='display:grid;flex:3;'></div>";
  680. echo "<div id='pali_era_pali' style='display:grid;flex:7;'></div>";
  681. echo "</div>";
  682. //echo date_format($vesakha_day,"Y-m-d")."|".date_format($vesakha_day_1,"Y-m-d")
  683. echo "</div>";
  684. ?>
  685. <script language="javascript">
  686. //設定經緯度
  687. var g_coordinate_this=new Object;
  688. getLocation();
  689. g_coordinate_this=get_coordinate_num("selected");
  690. if(g_coordinate_this.AT==0 || g_coordinate_this.LT==0){
  691. g_coordinate_this.AT=7.738562;
  692. g_coordinate_this.LT=80.519675;
  693. }
  694. function angle_trans(angle){
  695. var angle_str="";
  696. var num_d=Math.floor(angle);
  697. var num_m=Math.floor((angle-num_d)*60);
  698. var num_s=Math.round((angle-num_d)*60-num_m);
  699. if(num_d!=0){
  700. angle_str+=num_d+"°";
  701. }
  702. if(num_m!=0){
  703. angle_str+=num_m+"’";
  704. }
  705. if(num_s!=0){
  706. angle_str+=num_s+"”";
  707. }
  708. return(angle_str);
  709. }
  710. function dawn_noon_display(){
  711. var Unix_string=document.getElementById('time_string').innerHTML
  712. var Unix_Array=Unix_string.split("-");
  713. var time_A=new Date();
  714. var time_B=new Date();
  715. $("#clock_string_X").html(gLocal.gui.now_time+":")
  716. var note_str="";
  717. var sun_hd_str=angle_trans(Unix_Array[4]/Math.PI*180);
  718. var hori_ref_time=Math.floor(Unix_Array[5]/60)+gLocal.gui.mins;
  719. hori_ref_time+=Math.floor(Unix_Array[5]%60)+gLocal.gui.sec;
  720. note_str+=gLocal.gui.note+":";
  721. note_str+=gLocal.gui.sun_height_degree+" "+sun_hd_str+";";
  722. note_str+=gLocal.gui.hori_ref_time+" "+hori_ref_time;
  723. $("#hori_ref").html(note_str);
  724. if(g_Unix_now<Unix_Array[0]){
  725. time_A.setTime(Unix_Array[1])
  726. time_B.setTime(Unix_Array[0])
  727. $("#time_A_string_X").html(gLocal.gui.noon_time+":");
  728. $("#time_A_string").html(set_time_string(time_A));
  729. $("#time_B_string_X").html(gLocal.gui.twilight_time+":");
  730. $("#time_B_string").html(set_time_string(time_B));
  731. $("#kala_judge").html("【"+gLocal.gui.vikala+"】");
  732. $("#kala_inst_1").html(gLocal.gui.no_string+gLocal.gui.eat);
  733. $("#kala_inst_2").html(gLocal.gui.need_inform+gLocal.gui.no_string+gLocal.gui.gama_entry);
  734. }
  735. else if(g_Unix_now>=Unix_Array[0] && g_Unix_now<Unix_Array[1]){
  736. time_A.setTime(Unix_Array[0])
  737. time_B.setTime(Unix_Array[1])
  738. $("#time_A_string_X").html(gLocal.gui.twilight_time+":");
  739. $("#time_A_string").html(set_time_string(time_A));
  740. $("#time_B_string_X").html(gLocal.gui.noon_time+":");
  741. $("#time_B_string").html(set_time_string(time_B));
  742. $("#kala_judge").html("【"+gLocal.gui.kala+"】");
  743. $("#kala_inst_1").html(gLocal.gui.yes_string+gLocal.gui.eat);
  744. $("#kala_inst_2").html(gLocal.gui.need_inform+gLocal.gui.yes_string+gLocal.gui.gama_entry);
  745. }
  746. else if(g_Unix_now>=Unix_Array[1] && g_Unix_now<Unix_Array[2]){
  747. time_A.setTime(Unix_Array[1])
  748. time_B.setTime(Unix_Array[2])
  749. $("#time_A_string_X").html(gLocal.gui.noon_time+":");
  750. $("#time_A_string").html(set_time_string(time_A));
  751. $("#time_B_string_X").html(gLocal.gui.twilight_time+":");
  752. $("#time_B_string").html(set_time_string(time_B));
  753. $("#kala_judge").html("【"+gLocal.gui.vikala+"】");
  754. $("#kala_inst_1").html(gLocal.gui.no_string+gLocal.gui.eat);
  755. $("#kala_inst_2").html(gLocal.gui.need_inform+gLocal.gui.no_string+gLocal.gui.gama_entry);
  756. }
  757. t=setTimeout('dawn_noon_display()',1000)
  758. }
  759. function set_time_string(date_obj){
  760. var hh=date_obj.getHours()
  761. var mm=date_obj.getMinutes()
  762. var ss=date_obj.getSeconds()
  763. // add a zero in front of numbers<10
  764. hh=checkTime(hh)
  765. mm=checkTime(mm)
  766. ss=checkTime(ss)
  767. return(hh+":"+mm+":"+ss)
  768. }
  769. function menuLangrage(obj,year,month){
  770. g_language=obj.value;
  771. setCookie('language',g_language,365);
  772. window.location.assign("index.php?language="+g_language+"&y="+year+"&m="+month);
  773. }
  774. set_uposatha_day();
  775. set_cur_day_era();
  776. function set_cur_day_era(){
  777. if(document.getElementById('cur_day_string')!=null){
  778. var cur_day_string=document.getElementById('cur_day_string').innerHTML;
  779. var cur_date=cur_day_string.split("-")[0];
  780. var cur_years_diff_total=cur_day_string.split("-")[1];
  781. var cur_days_diff=cur_day_string.split("-")[2];
  782. var cur_week_day=cur_day_string.split("-")[3];
  783. var currLanguage=cur_day_string.split("-")[4];
  784. pali_date(cur_date,cur_years_diff_total,cur_days_diff,cur_week_day,currLanguage,g_coordinate_this);
  785. }
  786. }
  787. function set_uposatha_day(){
  788. var key_num=document.getElementById('key_num_string').innerHTML;
  789. var total_days=key_num.split("-")[0];
  790. var month_days=key_num.split("-")[1];
  791. var year=key_num.split("-")[2];
  792. for(i_uposatha=1;i_uposatha<=month_days;i_uposatha++){
  793. var pres_obj=pali_date_num(year,total_days-month_days+i_uposatha)[1];
  794. var uposatha_obj=uposatha_calculator(pres_obj.month,pres_obj.day);
  795. var day_id="td_"+i_uposatha;
  796. if(uposatha_obj.uposatha && uposatha_obj.pakkha=="kāla"){
  797. //document.getElementById(day_id).innerHTML+="<svg class='icon'><use xlink:href='svg/icon.svg#new_moon'></use></svg>";
  798. document.getElementById(day_id).innerHTML="<div class='new_moon_uposatha' >"+i_uposatha+"</div>";
  799. }
  800. else if(uposatha_obj.uposatha && uposatha_obj.pakkha=="sukka"){
  801. //document.getElementById(day_id).innerHTML+="<svg class='icon'><use xlink:href='svg/icon.svg#full_moon'></use></svg>";
  802. document.getElementById(day_id).innerHTML="<div class='full_moon_uposatha' >"+i_uposatha+"</div>";
  803. }
  804. }
  805. }
  806. function pali_date_num(year,days){
  807. var date_num_array=new Array;
  808. var past_obj=new Object;
  809. var pres_obj=new Object;
  810. var left_obj=new Object;
  811. past_obj.year=Number(year);
  812. pres_obj.year=Number(year)+1;
  813. left_obj.year=5000-Number(year)-1;
  814. if(days%59<=30 && days%59!=0){//奇數月
  815. past_obj.month=Math.floor(days/59)*2;
  816. pres_obj.month=past_obj.month+1
  817. past_obj.day=days%59-1;
  818. pres_obj.day=days%59;
  819. pres_obj.month_length=30;
  820. if(pres_obj.month>=13){
  821. pres_obj.month=pres_obj.month%12;
  822. past_obj.month=pres_obj.month-1;
  823. past_obj.year=past_obj.year+Math.floor(pres_obj.month/12);
  824. pres_obj.year=past_obj.year+1;
  825. }
  826. }
  827. else if(days%59>30){//偶數月
  828. past_obj.month=Math.floor(days/59)*2+1;
  829. pres_obj.month=past_obj.month+1
  830. past_obj.day=days%59-30-1;
  831. pres_obj.day=past_obj.day+1
  832. pres_obj.month_length=29;
  833. }
  834. else if(days%59==0){//偶數月最後一天
  835. past_obj.month=days/59*2-1;
  836. pres_obj.month=past_obj.month+1
  837. past_obj.day=28;
  838. pres_obj.day=29;
  839. pres_obj.month_length=29;
  840. }
  841. left_obj.month=12-past_obj.month-1;
  842. left_obj.day=pres_obj.month_length-past_obj.day-1;
  843. date_num_array.push(past_obj,pres_obj,left_obj);
  844. return(date_num_array);
  845. }
  846. function get_coordinate_num(id_key){
  847. var LT=Number($("#LT_"+id_key+"_°")[0].value);
  848. LT+=Number($("#LT_"+id_key+"_’")[0].value)/60;
  849. LT+=Number($("#LT_"+id_key+"_”")[0].value)/3600;
  850. LT=Number($("#"+id_key+"_WE")[0].value+LT);
  851. var AT=Number($("#AT_"+id_key+"_°")[0].value);
  852. AT+=Number($("#AT_"+id_key+"_’")[0].value)/60;
  853. AT+=Number($("#AT_"+id_key+"_”")[0].value)/3600;
  854. AT=Number($("#"+id_key+"_NS")[0].value+AT);
  855. var coordinate_obj=new Object;
  856. coordinate_obj.LT=LT;
  857. coordinate_obj.AT=AT;
  858. return(coordinate_obj);
  859. }
  860. function pali_date(id,m_days,year,days,week_day,currLanguage,position){
  861. //改參數
  862. $('#cur_day_string').html(id+"-"+m_days+"-"+year+"-"+days+"-"+week_day+"-"+currLanguage);
  863. var coordinate=new Object;
  864. coordinate=g_coordinate_this;
  865. //var month=$("#sun_AT")[0].innerText.split('-')[0];
  866. var day_selected=$("#sun_AT")[0].innerText.split('-')[1];
  867. //選定日期
  868. var date_select=$("#key_num_string")[0].innerText.split('-')[2]+"-";
  869. date_select+=$("#key_num_string")[0].innerText.split('-')[3]+"-";
  870. date_select+=id;
  871. var year_str=$("#key_num_string")[0].innerText.split('-')[2];
  872. var month_str=$("#key_num_string")[0].innerText.split('-')[3];
  873. //var date_select=$("#date_picker")[0].value;
  874. $("#time_string").load("calendar_data.php?atitude="+coordinate.AT+"&longitude="+coordinate.LT+"&date="+date_select);
  875. //改變日曆中選中日的樣式
  876. for(var i_date=1;i_date<=m_days;i_date++){
  877. $("#td_"+i_date)[0].style="";
  878. }
  879. $("#td_"+id)[0].style="background:purple;";
  880. //佛曆數據解析
  881. var date_num_array=pali_date_num(year,days);
  882. var past=date_num_array[0];
  883. var pres=date_num_array[1];
  884. var left=date_num_array[2];
  885. //生成佛曆圖表外殻
  886. var pres_date_string ="<span>"+gLocal.gui.BE+"</span>";
  887. pres_date_string+="<span style='font-size: 200%;'>";
  888. pres_date_string+=pres.year+gLocal.gui.year_1;
  889. pres_date_string+=pres.month+gLocal.gui.month_1;
  890. pres_date_string+=pres.day+gLocal.gui.day+"</span>";
  891. pres_date_string+="<span id='BE_icon'></span>";
  892. $("#pali_era_graph").html(pres_date_string);
  893. //生成佛曆巴利外殻
  894. var past_date_string_pali ="<span id='past_string'></span>";
  895. var pres_date_string_pali ="<span id='pres_string'></span>";
  896. var left_date_string_pali ="<span id='left_string'></span>";
  897. var output_string_pali = past_date_string_pali+left_date_string_pali+pres_date_string_pali;
  898. $("#pali_era_pali").html(output_string_pali);
  899. //寫入佛曆圖表數據
  900. var pres_language_string_0= "";
  901. pres_language_string_0+=get_year_name(pres.year).string_0;
  902. pres_language_string_0+=get_month_name(pres.month,pres.day).string_0;
  903. pres_language_string_0+=get_week_day_name(week_day).string_0;
  904. var past_date_string ="<div>"+gLocal.gui.dhamma_time+"</div>"
  905. past_date_string+="<div><span class='BE_icon_span'>"+gLocal.gui.past+":</span>";
  906. past_date_string+=past.year+gLocal.gui.years;
  907. if(past.month!=0){
  908. past_date_string+=past.month+gLocal.gui.months;
  909. }
  910. if(!(past.month==0 && past.day==0)){
  911. past_date_string+=gLocal.gui.and_another;
  912. }
  913. if(past.day!=0){
  914. past_date_string+=past.day+gLocal.gui.days;
  915. }
  916. past_date_string+="</div>";
  917. var left_date_string= "<div><span class='BE_icon_span'>"+gLocal.gui.left+":</span>";
  918. left_date_string+=left.year+gLocal.gui.years;
  919. if(left.month!=0){
  920. left_date_string+=left.month+gLocal.gui.months;
  921. }
  922. if(!(left.month==0 && left.day==0)){
  923. left_date_string+=gLocal.gui.and_another;
  924. }
  925. if(left.day!=0){
  926. left_date_string+=left.day+gLocal.gui.days;
  927. }
  928. left_date_string+="</div>";
  929. $('#BE_icon').html(pres_language_string_0+"<br>"+past_date_string+left_date_string);
  930. //解析佛曆數據為文字
  931. var past_language_string="";
  932. var pres_language_string="";
  933. var left_language_string="";
  934. var pali_begin="idāni kho pana ";
  935. var pali_past_end=" atikkantāni.";
  936. var pali_left_end=" avasiṭṭhāni.";
  937. if(past.day==1 && past.month!=0){
  938. past_language_string+=pali_begin;
  939. past_language_string+=get_year_pali_string(past.year)+"ceva, ";
  940. past_language_string+=get_day_pali_string(past.day).pre;
  941. past_language_string+=get_month_pali_string(past.month).suff
  942. past_language_string+=pali_past_end;
  943. }
  944. else if(past.day==1 && past.month==0){
  945. past_language_string+=pali_begin;
  946. past_language_string+=get_day_pali_string(past.day).pre;
  947. past_language_string+=get_year_pali_string(past.year);
  948. past_language_string+=get_month_pali_string(past.month).suff
  949. past_language_string+=pali_past_end;
  950. }
  951. else if(past.day==0 && past.month==1){
  952. past_language_string+=pali_begin;
  953. past_language_string+=get_day_pali_string(past.month).pre;
  954. past_language_string+=get_year_pali_string(past.year)+"ceva, "
  955. past_language_string+=get_month_pali_string(past.day).suff
  956. past_language_string+=pali_past_end;
  957. }
  958. else if(past.day==0 && past.month>1){
  959. past_language_string+=pali_begin;
  960. past_language_string+=get_year_pali_string(past.year)
  961. past_language_string+=get_month_pali_string(past.month).suff;
  962. past_language_string+=get_day_pali_string(past.day).suff;
  963. past_language_string+=pali_past_end;
  964. }
  965. else{
  966. past_language_string+=pali_begin;
  967. past_language_string+=get_year_pali_string(past.year)
  968. past_language_string+=get_month_pali_string(past.month).suff+"ca, ";
  969. past_language_string+=get_day_pali_string(past.day).suff;
  970. past_language_string+=pali_past_end;
  971. }
  972. if(left.day==1 && left.month!=0){
  973. left_language_string+=get_year_pali_string(left.year)+"ceva, ";
  974. left_language_string+=get_day_pali_string(left.day).pre;
  975. left_language_string+=get_month_pali_string(left.month).suff;
  976. left_language_string+=pali_left_end;
  977. }
  978. else if(left.day==1 && left.month==0){
  979. left_language_string+=get_day_pali_string(left.day).pre;
  980. left_language_string+=get_year_pali_string(left.year);
  981. left_language_string+=get_month_pali_string(left.month).suff
  982. left_language_string+=pali_left_end;
  983. }
  984. else if(left.day==0 && left.month==1){
  985. left_language_string+=get_day_pali_string(left.month).pre;
  986. left_language_string+=get_year_pali_string(left.year)+"ceva, ";
  987. left_language_string+=get_month_pali_string(left.day).suff
  988. left_language_string+=pali_left_end;
  989. }
  990. else if(left.day==0 && left.month>1){
  991. left_language_string+=get_year_pali_string(left.year);
  992. left_language_string+=get_month_pali_string(left.month).suff;
  993. left_language_string+=get_day_pali_string(left.day).suff;
  994. left_language_string+=pali_left_end;
  995. }
  996. else{
  997. left_language_string+=get_year_pali_string(left.year);
  998. left_language_string+=get_month_pali_string(left.month).suff+"ca, ";
  999. left_language_string+=get_day_pali_string(left.day).suff;
  1000. left_language_string+=pali_left_end;
  1001. }
  1002. pres_language_string+=get_year_name(pres.year).string_1;
  1003. pres_language_string+=get_month_name(pres.month,pres.day).string_1;
  1004. pres_language_string+=get_week_day_name(week_day).string_1;
  1005. switch(currLanguage){
  1006. case "si":
  1007. for(i_sinhala in char_unicode_to_si_n){
  1008. eval("past_language_string=past_language_string.replace(/"+char_unicode_to_si_n[i_sinhala].id+"/g,char_unicode_to_si_n[i_sinhala].value);");
  1009. eval("pres_language_string=pres_language_string.replace(/"+char_unicode_to_si_n[i_sinhala].id+"/g,char_unicode_to_si_n[i_sinhala].value);");
  1010. eval("left_language_string=left_language_string.replace(/"+char_unicode_to_si_n[i_sinhala].id+"/g,char_unicode_to_si_n[i_sinhala].value);");
  1011. }
  1012. break;
  1013. case "my":
  1014. for(r_to_m_i in char_roman_to_myn){
  1015. eval("past_language_string=past_language_string.replace(/"+char_roman_to_myn[r_to_m_i].id+"/g,char_roman_to_myn[r_to_m_i].value);");
  1016. eval("pres_language_string=pres_language_string.replace(/"+char_roman_to_myn[r_to_m_i].id+"/g,char_roman_to_myn[r_to_m_i].value);");
  1017. eval("left_language_string=left_language_string.replace(/"+char_roman_to_myn[r_to_m_i].id+"/g,char_roman_to_myn[r_to_m_i].value);");
  1018. }
  1019. break;
  1020. default:
  1021. past_language_string=past_language_string.charAt(0).toUpperCase()+past_language_string.slice(1);
  1022. left_language_string=left_language_string.charAt(0).toUpperCase()+left_language_string.slice(1);
  1023. //pres_language_string=pres_language_string;
  1024. var new_string=pres_language_string.charAt(0).toUpperCase();
  1025. new_string+=pres_language_string.split('\. ')[0].slice(1)+". ";
  1026. new_string+=pres_language_string.split('\. ')[1].charAt(0).toUpperCase();
  1027. new_string+=pres_language_string.split('\. ')[1].slice(1);
  1028. pres_language_string=new_string;
  1029. }
  1030. $('#past_string').html(past_language_string);
  1031. $('#pres_string').html(pres_language_string);
  1032. $('#left_string').html(left_language_string);
  1033. }
  1034. function get_year_pali_string(year){
  1035. if(year>999){
  1036. year=year.toString()
  1037. Tp=year.charAt(0)*1000;
  1038. Hp=year.charAt(1)*100;
  1039. Sp=year.slice(2,4);
  1040. }
  1041. for(i_year in pali_num_str){
  1042. if(Tp==pali_num_str[i_year].id){
  1043. var Tp_string=pali_num_str[i_year].value;
  1044. }
  1045. if(Hp==pali_num_str[i_year].id){
  1046. var Hp_string=pali_num_str[i_year].value;
  1047. }
  1048. if(Sp==pali_num_str[i_year].id){
  1049. var Sp_string=pali_num_str[i_year].value;
  1050. }
  1051. }
  1052. if(year==1){
  1053. var year_pali_end=" saṃvaccharaṃ ceva, ";
  1054. }
  1055. else{
  1056. var year_pali_end=" saṃvaccharāni ";
  1057. }
  1058. var year_string=Tp_string+"-"+Hp_string+"-"+Sp_string+year_pali_end;
  1059. return(year_string);
  1060. }
  1061. function get_month_pali_string(month){
  1062. var month_obj=new Object;
  1063. if(month>=2){
  1064. month=month.toString();
  1065. for(i_month in pali_num_str_pl){
  1066. if(month==pali_num_str_pl[i_month].id){
  1067. var month_num_string=pali_num_str_pl[i_month].value;
  1068. }
  1069. }
  1070. month_obj.suff=month_num_string+" māsāni "
  1071. month_obj.pre="";
  1072. }
  1073. else if(month==1){
  1074. month_obj.suff="dve-pakkhāni";
  1075. month_obj.pre="eka-māsādhika-";
  1076. }
  1077. else if(month==0){
  1078. month_obj.suff="";
  1079. month_obj.pre="";
  1080. }
  1081. return(month_obj);
  1082. }
  1083. function get_day_pali_string(day){
  1084. var day_obj=new Object;
  1085. if(day>=2){
  1086. day=day.toString();
  1087. for(i_day in pali_num_str_pl){
  1088. if(day==pali_num_str_pl[i_day].id){
  1089. var day_num_string=pali_num_str_pl[i_day].value;
  1090. }
  1091. }
  1092. day_obj.suff=day_num_string+" divasāni "
  1093. day_obj.pre="";
  1094. }
  1095. else if(day==1){
  1096. day_obj.suff="";
  1097. day_obj.pre="eka-divasādhika-";
  1098. }
  1099. else if(day==0){
  1100. day_obj.suff="";
  1101. day_obj.pre="";
  1102. }
  1103. return(day_obj);
  1104. }
  1105. function get_year_name(year){
  1106. var year_num=year%12;
  1107. var year_name_string=new Object;
  1108. for(i_year_name in pali_year_name){
  1109. if(year_num==pali_year_name[i_year_name].id){
  1110. year_name_string.value=pali_year_name[i_year_name].value;
  1111. year_name_string.icon=pali_year_name[i_year_name].icon;
  1112. }
  1113. }
  1114. year_name_string.string_0 ="<div><span class='BE_icon_span'>"+gLocal.gui.year_0+"</span>";
  1115. year_name_string.string_0+=year_name_string.icon+"</div>";
  1116. year_name_string.string_1="ayaṃ "+year_name_string.value+"-saṃvacchare ";
  1117. return(year_name_string);
  1118. }
  1119. function uposatha_calculator(month,day){
  1120. var day_obj=new Object;
  1121. if(month%2==1){
  1122. var days_per_month=30;
  1123. }
  1124. else{
  1125. var days_per_month=29;
  1126. }
  1127. if(days_per_month==30){
  1128. if(day<=15){
  1129. day_obj.day=day;
  1130. day_obj.pakkha="kāla "+gLocal.gui.kala_pakkha;
  1131. day_obj.pakkha_icon="🌖→🌑";
  1132. if(day==15){
  1133. day_obj.uposatha=true;
  1134. }
  1135. else{
  1136. day_obj.uposatha=false;
  1137. }
  1138. }
  1139. else{
  1140. day_obj.day=day-15;
  1141. day_obj.pakkha="sukka";//🌕🌗🌗🌒🌓🌔🌝🌚🌞🌜🌛
  1142. day_obj.pakkha_icon="🌒→🌕";
  1143. if(day==30){
  1144. day_obj.uposatha=true;
  1145. }
  1146. else{
  1147. day_obj.uposatha=false;
  1148. }
  1149. }
  1150. }
  1151. else if(days_per_month==29){
  1152. if(day<=14){
  1153. day_obj.day=day;
  1154. day_obj.pakkha="kāla";
  1155. day_obj.pakkha_icon="🌖→🌑";
  1156. if(day==14){
  1157. day_obj.uposatha=true;
  1158. }
  1159. else{
  1160. day_obj.uposatha=false;
  1161. }
  1162. }
  1163. else{
  1164. day_obj.day=day-14;
  1165. day_obj.pakkha="sukka";
  1166. day_obj.pakkha_icon="🌒→🌕";
  1167. if(day==29){
  1168. day_obj.uposatha=true;
  1169. }
  1170. else{
  1171. day_obj.uposatha=false;
  1172. }
  1173. }
  1174. }
  1175. return(day_obj);
  1176. }
  1177. function get_month_name(month,day){
  1178. var return_string=new Object;
  1179. for(i_month_name in pali_month_name){
  1180. if(month==pali_month_name[i_month_name].id){
  1181. var month_name_string=pali_month_name[i_month_name].value;
  1182. var season_name_string=pali_month_name[i_month_name].season;
  1183. var season_icon_string=pali_month_name[i_month_name].season_icon;
  1184. }
  1185. }
  1186. return_string.string_0 ="<div><span class='BE_icon_span'>"+gLocal.gui.season+"</span>";
  1187. return_string.string_0+=season_icon_string+"</div>";
  1188. return_string.string_0+="<div><span class='BE_icon_span'>"+gLocal.gui.month+"</span>";
  1189. return_string.string_0+=month_name_string+"</div>";
  1190. return_string.string_1=season_name_string+"-utu. "
  1191. return_string.string_1+="asmiṃ utumhi "+month_name_string+"-māsassa ";
  1192. var day_object=uposatha_calculator(month,day);
  1193. for(i_day_name in pali_date_name){
  1194. if(day_object.day==pali_date_name[i_day_name].id){
  1195. day_name_string=pali_date_name[i_day_name].value;
  1196. var day_num_string=day_object.day
  1197. }
  1198. }
  1199. var pakkha_name_string=day_object.pakkha+"-pakkhe "+day_name_string;
  1200. return_string.string_0+="<div><span class='BE_icon_span'>"+gLocal.gui.pakkha+"</span>";
  1201. return_string.string_0+=day_object.pakkha_icon+"</div>";
  1202. return_string.string_0+="<div><span class='BE_icon_span'>"+gLocal.gui.date+"</span>";
  1203. return_string.string_0+=day_num_string+"</div>";
  1204. return_string.string_1+=pakkha_name_string+", ";
  1205. return(return_string);
  1206. }
  1207. function get_week_day_name(week_day){
  1208. var week_day_string=new Object;
  1209. for(i_week in pali_week_day_name){
  1210. if(week_day==pali_week_day_name[i_week].id){
  1211. week_day_string.string_0=pali_week_day_name[i_week].value
  1212. week_day_string.string_1=pali_week_day_name[i_week].value
  1213. }
  1214. }
  1215. week_day_string.string_0="<div><span class='BE_icon_span'>"+gLocal.gui.week_day+"</span>"+week_day_string.string_0+"</div>";
  1216. week_day_string.string_1+="-varamidan’ti daṭṭhabbaṃ."
  1217. return(week_day_string);
  1218. }
  1219. function set_display(hide_id,show_id){
  1220. $("#"+show_id).show();
  1221. $("#"+hide_id).hide();
  1222. }
  1223. function confirm_position(hide_id,show_id,position){
  1224. $("#"+show_id).show();
  1225. $("#"+hide_id).hide();
  1226. var LT_str="";
  1227. if($("#LT_"+position+"_°")[0].value!=0){
  1228. LT_str+=$("#LT_"+position+"_°")[0].value+"°";
  1229. }
  1230. if($("#LT_"+position+"_’")[0].value!=0){
  1231. LT_str+=$("#LT_"+position+"_’")[0].value+"’";
  1232. }
  1233. if($("#LT_"+position+"_”")[0].value!=0){
  1234. LT_str+=$("#LT_"+position+"_”")[0].value+"”";
  1235. }
  1236. if(LT_str!=""){
  1237. if($("#"+position+"_WE")[0].value=="+"){
  1238. LT_str+="E";
  1239. }
  1240. else{
  1241. LT_str+="W";
  1242. }
  1243. }
  1244. var AT_str="";
  1245. if($("#AT_"+position+"_°")[0].value!=0){
  1246. AT_str+=$("#AT_"+position+"_°")[0].value+"°";
  1247. }
  1248. if($("#AT_"+position+"_’")[0].value!=0){
  1249. AT_str+=$("#AT_"+position+"_’")[0].value+"’";
  1250. }
  1251. if($("#AT_"+position+"_”")[0].value!=0){
  1252. AT_str+=$("#AT_"+position+"_”")[0].value+"”";
  1253. }
  1254. if(AT_str!=""){
  1255. if($("#"+position+"_NS")[0].value=="+"){
  1256. AT_str+="N";
  1257. }
  1258. else{
  1259. AT_str+="S";
  1260. }
  1261. }
  1262. $("#"+position+"_position_string").html(LT_str+" "+AT_str);
  1263. }
  1264. function getLocation(){//自动定位
  1265. if(navigator.geolocation){
  1266. navigator.geolocation.getCurrentPosition(showPosition,showError);
  1267. }
  1268. else{
  1269. $("#selected_position_string").html("Geolocation is not supported by this browser.");
  1270. }
  1271. }
  1272. function showPosition(position){
  1273. alert("get cordinate success");
  1274. g_coordinate_this.AT=position.coords.latitude;
  1275. g_coordinate_this.LT=position.coords.longitude;
  1276. if(g_coordinate_this.AT>=0){
  1277. var AT_string=angle_trans(g_coordinate_this.AT)+"N";
  1278. }
  1279. else{
  1280. var AT_string=angle_trans(g_coordinate_this.AT)+"S";
  1281. }
  1282. if(g_coordinate_this.LT>=0){
  1283. var LT_string=angle_trans(g_coordinate_this.LT)+"E";
  1284. }
  1285. else{
  1286. var LT_string=angle_trans(g_coordinate_this.LT)+"W";
  1287. }
  1288. $("#selected_position_string").html(AT_string+" "+LT_string);
  1289. }
  1290. function showError(error){
  1291. switch(error.code) {
  1292. case error.PERMISSION_DENIED:
  1293. alert("定位失败,用户拒绝请求地理定位");
  1294. break;
  1295. case error.POSITION_UNAVAILABLE:
  1296. alert("定位失败,位置信息是不可用");
  1297. break;
  1298. case error.TIMEOUT:
  1299. alert("定位失败,请求获取用户位置超时");
  1300. break;
  1301. case error.UNKNOWN_ERROR:
  1302. alert("定位失败,定位系统失效");
  1303. break;
  1304. }
  1305. }
  1306. function confirm(){
  1307. confirm_position("position_input","position_change","selected")
  1308. var select_day_string=new Array();
  1309. select_day_string=$('#cur_day_string')[0].innerText.split('-');
  1310. pali_date(select_day_string[0],select_day_string[1],select_day_string[2],select_day_string[3],select_day_string[4],select_day_string[5],g_coordinate_this)
  1311. }
  1312. dawn_noon_display();
  1313. function air_confirm(place){
  1314. confirm_position(place+"_position_input",place+"_position_result",place);
  1315. var coordinate= get_coordinate_num(place);
  1316. var air_date=$("#"+place+"_date")[0].value;
  1317. var air_time=$("#"+place+"_time")[0].value;
  1318. $("#"+place+"_position_string")[0].innerText+=" "+air_date+" "+air_time;
  1319. $("#air_time_string").load("calendar_data.php?atitude="+coordinate.AT+"&longitude="+coordinate.LT+"&date="+air_date);
  1320. var air_noon_time=new Date();
  1321. air_noon_time.setTime($("#air_time_string")[0].innerText.split('-')[1]);
  1322. $("#"+place+"_position_string")[0].innerText+=gLocal.gui.noon_time+set_time_string(air_noon_time);
  1323. }
  1324. function computeSunRiseSunSet(Latitude, Longitude, TimeZone) {
  1325. var curTime = new Date();
  1326. // Variable names used: B5, C, C2, C3, CD, D, DR, H, HR, HS, L0, L5, M, MR, MS, N, PI, R1, RD, S1, SC, SD, str
  1327. var retVal = new Object();
  1328. var PI = Math.PI;
  1329. var DR = PI / 180;
  1330. var RD = 1 / DR;
  1331. var B5 = Latitude;
  1332. var L5 = Longitude;
  1333. var H = -1 * (curTime.getTimezoneOffset() / 60 * -1); // Local timezone
  1334. // Overriding TimeZone to standardize on UTC
  1335. // H = 0;
  1336. var M = curTime.getMonth() + 1;
  1337. var D = curTime.getDate();
  1338. B5 = DR * B5;
  1339. var N = parseInt(275 * M / 9) - 2 * parseInt((M + 9) / 12) + D - 30;
  1340. var L0 = 4.8771 + .0172 * (N + .5 - L5 / 360);
  1341. var C = .03342 * Math.sin(L0 + 1.345);
  1342. var C2 = RD * (Math.atan(Math.tan(L0 + C)) - Math.atan(.9175 * Math.tan(L0 + C)) - C);
  1343. var SD = .3978 * Math.sin(L0 + C);
  1344. var CD = Math.sqrt(1 - SD * SD);
  1345. var SC = (SD * Math.sin(B5) + .0145) / (Math.cos(B5) * CD);
  1346. if (Math.abs(SC) <= 1) {
  1347. var C3 = RD * Math.atan(SC / Math.sqrt(1 - SC * SC));
  1348. var R1 = 6 - H - (L5 + C2 + C3) / 15;
  1349. var HR = parseInt(R1);
  1350. var MR = parseInt((R1 - HR) * 60);
  1351. retVal.SunRise = parseTime(HR + ":" + MR);
  1352. var TargetTimezoneOffset = (TimeZone * 60 * 60 * 1000) + (retVal.SunRise.getTimezoneOffset() * 60 * 1000);
  1353. var transformedSunRise = new Date(retVal.SunRise.getTime() + TargetTimezoneOffset);
  1354. var strSunRise = "日出" + transformedSunRise.getHours() + ":" + (transformedSunRise.getMinutes() < 10 ? "0" + transformedSunRise.getMinutes() : transformedSunRise.getMinutes());
  1355. var S1 = 18 - H - (L5 + C2 - C3) / 15;
  1356. var HS = parseInt(S1);
  1357. var MS = parseInt((S1 - HS) * 60);
  1358. retVal.SunSet = parseTime(HS + ":" + MS);
  1359. var transformedSunSet = new Date(retVal.SunSet.getTime() + TargetTimezoneOffset);
  1360. var strSunSet = "日落" + transformedSunSet.getHours() + ":" + (transformedSunSet.getMinutes() < 10 ? "0" + transformedSunSet.getMinutes() : transformedSunSet.getMinutes());
  1361. retVal.Noon = new Date((retVal.SunRise.getTime() + retVal.SunSet.getTime()) / 2);
  1362. var transformedNoon = new Date(retVal.Noon.getTime() + TargetTimezoneOffset);
  1363. var strNoon = "正午" + transformedNoon.getHours() + ":" + (transformedNoon.getMinutes() < 10 ? "0" + transformedNoon.getMinutes() : transformedNoon.getMinutes());
  1364. }
  1365. else {
  1366. if (SC > 1) {
  1367. // str="Sun up all day";
  1368. strSunRise = ".";
  1369. strNoon = ".";
  1370. strSunSet = ".";
  1371. var tDate = new Date();
  1372. // Set Sunset to be in the future ...
  1373. retVal.SunSet = new Date(tDate.getFullYear() + 1, tDate.getMonth(), tDate.getDay(), tDate.getHours());
  1374. // Set Sunrise to be in the past ...
  1375. retVal.SunRise = new Date(tDate.getFullYear() - 1, tDate.getMonth(), tDate.getDay(), tDate.getHours() - 1);
  1376. }
  1377. if (SC < -1) {
  1378. // str="Sun down all day";
  1379. strSunRise = ".";
  1380. strNoon = ".";
  1381. strSunSet = ".";
  1382. // Set Sunrise and Sunset to be in the future ...
  1383. retVal.SunRise = new Date(tDate.getFullYear() + 1, tDate.getMonth(), tDate.getDay(), tDate.getHours());
  1384. retVal.SunSet = new Date(tDate.getFullYear() + 1, tDate.getMonth(), tDate.getDay(), tDate.getHours());
  1385. }
  1386. }
  1387. retVal.strSunRise = strSunRise;
  1388. retVal.strNoon = strNoon;
  1389. retVal.strSunSet = strSunSet;
  1390. retVal.str = strSunRise + ' | ' + strNoon + ' | ' + strSunSet;
  1391. return retVal;
  1392. }
  1393. ////////////////////////////////////////////////////////////////////////////////
  1394. //
  1395. // parseTime(string aTime) - takes a string of time in the format HH:MM:SS
  1396. // and returns Javascript Date Object
  1397. //
  1398. ////////////////////////////////////////////////////////////////////////////////
  1399. function parseTime(aTime) {
  1400. var aDateTimeObject = 'none';
  1401. if (aTime !== undefined && aTime.length) {
  1402. aDateTimeObject = GMTTime();
  1403. try {
  1404. var theHour = parseInt(aTime.split(':')[0]);
  1405. var theMinutes = parseInt(aTime.split(':')[1]);
  1406. aDateTimeObject.setHours(theHour);
  1407. aDateTimeObject.setMinutes(theMinutes);
  1408. }
  1409. catch (ex) {
  1410. }
  1411. }
  1412. return aDateTimeObject;
  1413. }
  1414. ////////////////////////////////////////////////////////////////////////////////
  1415. //
  1416. // GMTTime() - returns time adjusted to GMT (Universal Time)
  1417. //
  1418. ////////////////////////////////////////////////////////////////////////////////
  1419. function GMTTime() {
  1420. var aDate = new Date();
  1421. var aDateAdjustedToGMTInMS = aDate.getTime() + (aDate.getTimezoneOffset() * 60 * 1000);
  1422. return (new Date(aDateAdjustedToGMTInMS));
  1423. }
  1424. </script>