index.php 52 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495
  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->BE;?></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. */
  695. function angle_trans(angle){
  696. var angle_str="";
  697. var num_d=Math.floor(angle);
  698. var num_m=Math.floor((angle-num_d)*60);
  699. var num_s=Math.round((angle-num_d)*60-num_m);
  700. if(num_d!=0){
  701. angle_str+=num_d+"°";
  702. }
  703. if(num_m!=0){
  704. angle_str+=num_m+"’";
  705. }
  706. if(num_s!=0){
  707. angle_str+=num_s+"”";
  708. }
  709. return(angle_str);
  710. }
  711. function dawn_noon_display(){
  712. var Unix_string=document.getElementById('time_string').innerHTML
  713. var Unix_Array=Unix_string.split("-");
  714. var time_A=new Date();
  715. var time_B=new Date();
  716. $("#clock_string_X").html(gLocal.gui.now_time+":")
  717. var note_str="";
  718. var sun_hd_str=angle_trans(Unix_Array[4]/Math.PI*180);
  719. var hori_ref_time=Math.floor(Unix_Array[5]/60)+gLocal.gui.mins;
  720. hori_ref_time+=Math.floor(Unix_Array[5]%60)+gLocal.gui.sec;
  721. note_str+=gLocal.gui.note+":";
  722. note_str+=gLocal.gui.sun_height_degree+" "+sun_hd_str+";";
  723. note_str+=gLocal.gui.hori_ref_time+" "+hori_ref_time;
  724. $("#hori_ref").html(note_str);
  725. if(g_Unix_now<Unix_Array[0]){
  726. time_A.setTime(Unix_Array[1])
  727. time_B.setTime(Unix_Array[0])
  728. $("#time_A_string_X").html(gLocal.gui.noon_time+":");
  729. $("#time_A_string").html(set_time_string(time_A));
  730. $("#time_B_string_X").html(gLocal.gui.twilight_time+":");
  731. $("#time_B_string").html(set_time_string(time_B));
  732. $("#kala_judge").html("【"+gLocal.gui.vikala+"】");
  733. $("#kala_inst_1").html(gLocal.gui.no_string+gLocal.gui.eat);
  734. $("#kala_inst_2").html(gLocal.gui.need_inform+gLocal.gui.no_string+gLocal.gui.gama_entry);
  735. }
  736. else if(g_Unix_now>=Unix_Array[0] && g_Unix_now<Unix_Array[1]){
  737. time_A.setTime(Unix_Array[0])
  738. time_B.setTime(Unix_Array[1])
  739. $("#time_A_string_X").html(gLocal.gui.twilight_time+":");
  740. $("#time_A_string").html(set_time_string(time_A));
  741. $("#time_B_string_X").html(gLocal.gui.noon_time+":");
  742. $("#time_B_string").html(set_time_string(time_B));
  743. $("#kala_judge").html("【"+gLocal.gui.kala+"】");
  744. $("#kala_inst_1").html(gLocal.gui.yes_string+gLocal.gui.eat);
  745. $("#kala_inst_2").html(gLocal.gui.need_inform+gLocal.gui.yes_string+gLocal.gui.gama_entry);
  746. }
  747. else if(g_Unix_now>=Unix_Array[1] && g_Unix_now<Unix_Array[2]){
  748. time_A.setTime(Unix_Array[1])
  749. time_B.setTime(Unix_Array[2])
  750. $("#time_A_string_X").html(gLocal.gui.noon_time+":");
  751. $("#time_A_string").html(set_time_string(time_A));
  752. $("#time_B_string_X").html(gLocal.gui.twilight_time+":");
  753. $("#time_B_string").html(set_time_string(time_B));
  754. $("#kala_judge").html("【"+gLocal.gui.vikala+"】");
  755. $("#kala_inst_1").html(gLocal.gui.no_string+gLocal.gui.eat);
  756. $("#kala_inst_2").html(gLocal.gui.need_inform+gLocal.gui.no_string+gLocal.gui.gama_entry);
  757. }
  758. t=setTimeout('dawn_noon_display()',1000)
  759. }
  760. function set_time_string(date_obj){
  761. var hh=date_obj.getHours()
  762. var mm=date_obj.getMinutes()
  763. var ss=date_obj.getSeconds()
  764. // add a zero in front of numbers<10
  765. hh=checkTime(hh)
  766. mm=checkTime(mm)
  767. ss=checkTime(ss)
  768. //return(hh+":"+mm+":"+ss)
  769. return(date_obj.toLocaleTimeString())
  770. }
  771. function menuLangrage(obj,year,month){
  772. g_language=obj.value;
  773. setCookie('language',g_language,365);
  774. window.location.assign("index.php?language="+g_language+"&y="+year+"&m="+month);
  775. }
  776. set_uposatha_day();
  777. set_cur_day_era();
  778. function set_cur_day_era(){
  779. if(document.getElementById('cur_day_string')!=null){
  780. var cur_day_string=document.getElementById('cur_day_string').innerHTML;
  781. var cur_date=cur_day_string.split("-")[0];
  782. var cur_years_diff_total=cur_day_string.split("-")[1];
  783. var cur_days_diff=cur_day_string.split("-")[2];
  784. var cur_week_day=cur_day_string.split("-")[3];
  785. var currLanguage=cur_day_string.split("-")[4];
  786. pali_date(cur_date,cur_years_diff_total,cur_days_diff,cur_week_day,currLanguage,g_coordinate_this);
  787. }
  788. }
  789. function set_uposatha_day(){
  790. var key_num=document.getElementById('key_num_string').innerHTML;
  791. var total_days=key_num.split("-")[0];
  792. var month_days=key_num.split("-")[1];
  793. var year=key_num.split("-")[2];
  794. for(i_uposatha=1;i_uposatha<=month_days;i_uposatha++){
  795. var pres_obj=pali_date_num(year,total_days-month_days+i_uposatha)[1];
  796. var uposatha_obj=uposatha_calculator(pres_obj.month,pres_obj.day);
  797. var day_id="td_"+i_uposatha;
  798. if(uposatha_obj.uposatha && uposatha_obj.pakkha=="kāla"){
  799. //document.getElementById(day_id).innerHTML+="<svg class='icon'><use xlink:href='svg/icon.svg#new_moon'></use></svg>";
  800. document.getElementById(day_id).innerHTML="<div class='new_moon_uposatha' >"+i_uposatha+"</div>";
  801. }
  802. else if(uposatha_obj.uposatha && uposatha_obj.pakkha=="sukka"){
  803. //document.getElementById(day_id).innerHTML+="<svg class='icon'><use xlink:href='svg/icon.svg#full_moon'></use></svg>";
  804. document.getElementById(day_id).innerHTML="<div class='full_moon_uposatha' >"+i_uposatha+"</div>";
  805. }
  806. }
  807. }
  808. function pali_date_num(year,days){
  809. var date_num_array=new Array;
  810. var past_obj=new Object;
  811. var pres_obj=new Object;
  812. var left_obj=new Object;
  813. past_obj.year=Number(year);
  814. pres_obj.year=Number(year)+1;
  815. left_obj.year=5000-Number(year)-1;
  816. if(days%59<=30 && days%59!=0){//奇數月
  817. past_obj.month=Math.floor(days/59)*2;
  818. pres_obj.month=past_obj.month+1
  819. past_obj.day=days%59-1;
  820. pres_obj.day=days%59;
  821. pres_obj.month_length=30;
  822. if(pres_obj.month>=13){
  823. pres_obj.month=pres_obj.month%12;
  824. past_obj.month=pres_obj.month-1;
  825. past_obj.year=past_obj.year+Math.floor(pres_obj.month/12);
  826. pres_obj.year=past_obj.year+1;
  827. }
  828. }
  829. else if(days%59>30){//偶數月
  830. past_obj.month=Math.floor(days/59)*2+1;
  831. pres_obj.month=past_obj.month+1
  832. past_obj.day=days%59-30-1;
  833. pres_obj.day=past_obj.day+1
  834. pres_obj.month_length=29;
  835. }
  836. else if(days%59==0){//偶數月最後一天
  837. past_obj.month=days/59*2-1;
  838. pres_obj.month=past_obj.month+1
  839. past_obj.day=28;
  840. pres_obj.day=29;
  841. pres_obj.month_length=29;
  842. }
  843. left_obj.month=12-past_obj.month-1;
  844. left_obj.day=pres_obj.month_length-past_obj.day-1;
  845. date_num_array.push(past_obj,pres_obj,left_obj);
  846. return(date_num_array);
  847. }
  848. function get_coordinate_num(id_key){
  849. var LT=Number($("#LT_"+id_key+"_°")[0].value);
  850. LT+=Number($("#LT_"+id_key+"_’")[0].value)/60;
  851. LT+=Number($("#LT_"+id_key+"_”")[0].value)/3600;
  852. LT=Number($("#"+id_key+"_WE")[0].value+LT);
  853. var AT=Number($("#AT_"+id_key+"_°")[0].value);
  854. AT+=Number($("#AT_"+id_key+"_’")[0].value)/60;
  855. AT+=Number($("#AT_"+id_key+"_”")[0].value)/3600;
  856. AT=Number($("#"+id_key+"_NS")[0].value+AT);
  857. var coordinate_obj=new Object;
  858. coordinate_obj.LT=LT;
  859. coordinate_obj.AT=AT;
  860. return(coordinate_obj);
  861. }
  862. function pali_date(id,m_days,year,days,week_day,currLanguage,position){
  863. //改參數
  864. $('#cur_day_string').html(id+"-"+m_days+"-"+year+"-"+days+"-"+week_day+"-"+currLanguage);
  865. var coordinate=new Object;
  866. coordinate=g_coordinate_this;
  867. //var month=$("#sun_AT")[0].innerText.split('-')[0];
  868. var day_selected=$("#sun_AT")[0].innerText.split('-')[1];
  869. //選定日期
  870. var date_select=$("#key_num_string")[0].innerText.split('-')[2]+"-";
  871. date_select+=$("#key_num_string")[0].innerText.split('-')[3]+"-";
  872. date_select+=id;
  873. var year_str=$("#key_num_string")[0].innerText.split('-')[2];
  874. var month_str=$("#key_num_string")[0].innerText.split('-')[3];
  875. //var date_select=$("#date_picker")[0].value;
  876. $("#time_string").load("calendar_data.php?atitude="+coordinate.AT+"&longitude="+coordinate.LT+"&date="+date_select);
  877. //改變日曆中選中日的樣式
  878. for(var i_date=1;i_date<=m_days;i_date++){
  879. $("#td_"+i_date)[0].style="";
  880. }
  881. $("#td_"+id)[0].style="background:purple;";
  882. //佛曆數據解析
  883. var date_num_array=pali_date_num(year,days);
  884. var past=date_num_array[0];
  885. var pres=date_num_array[1];
  886. var left=date_num_array[2];
  887. //生成佛曆圖表外殻
  888. var pres_date_string ="<span>"+gLocal.gui.BE+"</span>";
  889. pres_date_string+="<span style='font-size: 200%;'>";
  890. pres_date_string+=pres.year+gLocal.gui.year_1;
  891. pres_date_string+=pres.month+gLocal.gui.month_1;
  892. pres_date_string+=pres.day+gLocal.gui.day+"</span>";
  893. pres_date_string+="<span id='BE_icon'></span>";
  894. $("#pali_era_graph").html(pres_date_string);
  895. //生成佛曆巴利外殻
  896. var past_date_string_pali ="<span id='past_string'></span>";
  897. var pres_date_string_pali ="<span id='pres_string'></span>";
  898. var left_date_string_pali ="<span id='left_string'></span>";
  899. var output_string_pali = past_date_string_pali+left_date_string_pali+pres_date_string_pali;
  900. $("#pali_era_pali").html(output_string_pali);
  901. //寫入佛曆圖表數據
  902. var pres_language_string_0= "";
  903. pres_language_string_0+=get_year_name(pres.year).string_0;
  904. pres_language_string_0+=get_month_name(pres.month,pres.day).string_0;
  905. pres_language_string_0+=get_week_day_name(week_day).string_0;
  906. var past_date_string ="<div>"+gLocal.gui.dhamma_time+"</div>"
  907. past_date_string+="<div><span class='BE_icon_span'>"+gLocal.gui.past+":</span>";
  908. past_date_string+=past.year+gLocal.gui.years;
  909. if(past.month!=0){
  910. past_date_string+=past.month+gLocal.gui.months;
  911. }
  912. if(!(past.month==0 && past.day==0)){
  913. past_date_string+=gLocal.gui.and_another;
  914. }
  915. if(past.day!=0){
  916. past_date_string+=past.day+gLocal.gui.days;
  917. }
  918. past_date_string+="</div>";
  919. var left_date_string= "<div><span class='BE_icon_span'>"+gLocal.gui.left+":</span>";
  920. left_date_string+=left.year+gLocal.gui.years;
  921. if(left.month!=0){
  922. left_date_string+=left.month+gLocal.gui.months;
  923. }
  924. if(!(left.month==0 && left.day==0)){
  925. left_date_string+=gLocal.gui.and_another;
  926. }
  927. if(left.day!=0){
  928. left_date_string+=left.day+gLocal.gui.days;
  929. }
  930. left_date_string+="</div>";
  931. $('#BE_icon').html(pres_language_string_0+"<br>"+past_date_string+left_date_string);
  932. //解析佛曆數據為文字
  933. var past_language_string="";
  934. var pres_language_string="";
  935. var left_language_string="";
  936. var pali_begin="idāni kho pana ";
  937. var pali_past_end=" atikkantāni.";
  938. var pali_left_end=" avasiṭṭhāni.";
  939. if(past.day==1 && past.month!=0){
  940. past_language_string+=pali_begin;
  941. past_language_string+=get_year_pali_string(past.year)+"ceva, ";
  942. past_language_string+=get_day_pali_string(past.day).pre;
  943. past_language_string+=get_month_pali_string(past.month).suff
  944. past_language_string+=pali_past_end;
  945. }
  946. else if(past.day==1 && past.month==0){
  947. past_language_string+=pali_begin;
  948. past_language_string+=get_day_pali_string(past.day).pre;
  949. past_language_string+=get_year_pali_string(past.year);
  950. past_language_string+=get_month_pali_string(past.month).suff
  951. past_language_string+=pali_past_end;
  952. }
  953. else if(past.day==0 && past.month==1){
  954. past_language_string+=pali_begin;
  955. past_language_string+=get_day_pali_string(past.month).pre;
  956. past_language_string+=get_year_pali_string(past.year)+"ceva, "
  957. past_language_string+=get_month_pali_string(past.day).suff
  958. past_language_string+=pali_past_end;
  959. }
  960. else if(past.day==0 && past.month>1){
  961. past_language_string+=pali_begin;
  962. past_language_string+=get_year_pali_string(past.year)
  963. past_language_string+=get_month_pali_string(past.month).suff;
  964. past_language_string+=get_day_pali_string(past.day).suff;
  965. past_language_string+=pali_past_end;
  966. }
  967. else{
  968. past_language_string+=pali_begin;
  969. past_language_string+=get_year_pali_string(past.year)
  970. past_language_string+=get_month_pali_string(past.month).suff+"ca, ";
  971. past_language_string+=get_day_pali_string(past.day).suff;
  972. past_language_string+=pali_past_end;
  973. }
  974. if(left.day==1 && left.month!=0){
  975. left_language_string+=get_year_pali_string(left.year)+"ceva, ";
  976. left_language_string+=get_day_pali_string(left.day).pre;
  977. left_language_string+=get_month_pali_string(left.month).suff;
  978. left_language_string+=pali_left_end;
  979. }
  980. else if(left.day==1 && left.month==0){
  981. left_language_string+=get_day_pali_string(left.day).pre;
  982. left_language_string+=get_year_pali_string(left.year);
  983. left_language_string+=get_month_pali_string(left.month).suff
  984. left_language_string+=pali_left_end;
  985. }
  986. else if(left.day==0 && left.month==1){
  987. left_language_string+=get_day_pali_string(left.month).pre;
  988. left_language_string+=get_year_pali_string(left.year)+"ceva, ";
  989. left_language_string+=get_month_pali_string(left.day).suff
  990. left_language_string+=pali_left_end;
  991. }
  992. else if(left.day==0 && left.month>1){
  993. left_language_string+=get_year_pali_string(left.year);
  994. left_language_string+=get_month_pali_string(left.month).suff;
  995. left_language_string+=get_day_pali_string(left.day).suff;
  996. left_language_string+=pali_left_end;
  997. }
  998. else{
  999. left_language_string+=get_year_pali_string(left.year);
  1000. left_language_string+=get_month_pali_string(left.month).suff+"ca, ";
  1001. left_language_string+=get_day_pali_string(left.day).suff;
  1002. left_language_string+=pali_left_end;
  1003. }
  1004. pres_language_string+=get_year_name(pres.year).string_1;
  1005. pres_language_string+=get_month_name(pres.month,pres.day).string_1;
  1006. pres_language_string+=get_week_day_name(week_day).string_1;
  1007. switch(currLanguage){
  1008. case "si":
  1009. for(i_sinhala in char_unicode_to_si_n){
  1010. 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);");
  1011. 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);");
  1012. 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);");
  1013. }
  1014. break;
  1015. case "my":
  1016. for(r_to_m_i in char_roman_to_myn){
  1017. 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);");
  1018. 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);");
  1019. 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);");
  1020. }
  1021. break;
  1022. default:
  1023. past_language_string=past_language_string.charAt(0).toUpperCase()+past_language_string.slice(1);
  1024. left_language_string=left_language_string.charAt(0).toUpperCase()+left_language_string.slice(1);
  1025. //pres_language_string=pres_language_string;
  1026. var new_string=pres_language_string.charAt(0).toUpperCase();
  1027. new_string+=pres_language_string.split('\. ')[0].slice(1)+". ";
  1028. new_string+=pres_language_string.split('\. ')[1].charAt(0).toUpperCase();
  1029. new_string+=pres_language_string.split('\. ')[1].slice(1);
  1030. pres_language_string=new_string;
  1031. }
  1032. $('#past_string').html(past_language_string);
  1033. $('#pres_string').html(pres_language_string);
  1034. $('#left_string').html(left_language_string);
  1035. }
  1036. function get_year_pali_string(year){
  1037. if(year>999){
  1038. year=year.toString()
  1039. Tp=year.charAt(0)*1000;
  1040. Hp=year.charAt(1)*100;
  1041. Sp=year.slice(2,4);
  1042. }
  1043. for(i_year in pali_num_str){
  1044. if(Tp==pali_num_str[i_year].id){
  1045. var Tp_string=pali_num_str[i_year].value;
  1046. }
  1047. if(Hp==pali_num_str[i_year].id){
  1048. var Hp_string=pali_num_str[i_year].value;
  1049. }
  1050. if(Sp==pali_num_str[i_year].id){
  1051. var Sp_string=pali_num_str[i_year].value;
  1052. }
  1053. }
  1054. if(year==1){
  1055. var year_pali_end=" saṃvaccharaṃ ceva, ";
  1056. }
  1057. else{
  1058. var year_pali_end=" saṃvaccharāni ";
  1059. }
  1060. var year_string=Tp_string+"-"+Hp_string+"-"+Sp_string+year_pali_end;
  1061. return(year_string);
  1062. }
  1063. function get_month_pali_string(month){
  1064. var month_obj=new Object;
  1065. if(month>=2){
  1066. month=month.toString();
  1067. for(i_month in pali_num_str_pl){
  1068. if(month==pali_num_str_pl[i_month].id){
  1069. var month_num_string=pali_num_str_pl[i_month].value;
  1070. }
  1071. }
  1072. month_obj.suff=month_num_string+" māsāni "
  1073. month_obj.pre="";
  1074. }
  1075. else if(month==1){
  1076. month_obj.suff="dve-pakkhāni";
  1077. month_obj.pre="eka-māsādhika-";
  1078. }
  1079. else if(month==0){
  1080. month_obj.suff="";
  1081. month_obj.pre="";
  1082. }
  1083. return(month_obj);
  1084. }
  1085. function get_day_pali_string(day){
  1086. var day_obj=new Object;
  1087. if(day>=2){
  1088. day=day.toString();
  1089. for(i_day in pali_num_str_pl){
  1090. if(day==pali_num_str_pl[i_day].id){
  1091. var day_num_string=pali_num_str_pl[i_day].value;
  1092. }
  1093. }
  1094. day_obj.suff=day_num_string+" divasāni "
  1095. day_obj.pre="";
  1096. }
  1097. else if(day==1){
  1098. day_obj.suff="";
  1099. day_obj.pre="eka-divasādhika-";
  1100. }
  1101. else if(day==0){
  1102. day_obj.suff="";
  1103. day_obj.pre="";
  1104. }
  1105. return(day_obj);
  1106. }
  1107. function get_year_name(year){
  1108. var year_num=year%12;
  1109. var year_name_string=new Object;
  1110. for(i_year_name in pali_year_name){
  1111. if(year_num==pali_year_name[i_year_name].id){
  1112. year_name_string.value=pali_year_name[i_year_name].value;
  1113. year_name_string.icon=pali_year_name[i_year_name].icon;
  1114. }
  1115. }
  1116. year_name_string.string_0 ="<div><span class='BE_icon_span'>"+gLocal.gui.year_0+"</span>";
  1117. year_name_string.string_0+=year_name_string.icon+"</div>";
  1118. year_name_string.string_1="ayaṃ "+year_name_string.value+"-saṃvacchare ";
  1119. return(year_name_string);
  1120. }
  1121. function uposatha_calculator(month,day){
  1122. var day_obj=new Object;
  1123. if(month%2==1){
  1124. var days_per_month=30;
  1125. }
  1126. else{
  1127. var days_per_month=29;
  1128. }
  1129. if(days_per_month==30){
  1130. if(day<=15){
  1131. day_obj.day=day;
  1132. day_obj.pakkha="kāla "+gLocal.gui.kala_pakkha;
  1133. day_obj.pakkha_icon="🌖→🌑";
  1134. if(day==15){
  1135. day_obj.uposatha=true;
  1136. }
  1137. else{
  1138. day_obj.uposatha=false;
  1139. }
  1140. }
  1141. else{
  1142. day_obj.day=day-15;
  1143. day_obj.pakkha="sukka";//🌕🌗🌗🌒🌓🌔🌝🌚🌞🌜🌛
  1144. day_obj.pakkha_icon="🌒→🌕";
  1145. if(day==30){
  1146. day_obj.uposatha=true;
  1147. }
  1148. else{
  1149. day_obj.uposatha=false;
  1150. }
  1151. }
  1152. }
  1153. else if(days_per_month==29){
  1154. if(day<=14){
  1155. day_obj.day=day;
  1156. day_obj.pakkha="kāla";
  1157. day_obj.pakkha_icon="🌖→🌑";
  1158. if(day==14){
  1159. day_obj.uposatha=true;
  1160. }
  1161. else{
  1162. day_obj.uposatha=false;
  1163. }
  1164. }
  1165. else{
  1166. day_obj.day=day-14;
  1167. day_obj.pakkha="sukka";
  1168. day_obj.pakkha_icon="🌒→🌕";
  1169. if(day==29){
  1170. day_obj.uposatha=true;
  1171. }
  1172. else{
  1173. day_obj.uposatha=false;
  1174. }
  1175. }
  1176. }
  1177. return(day_obj);
  1178. }
  1179. function get_month_name(month,day){
  1180. var return_string=new Object;
  1181. for(i_month_name in pali_month_name){
  1182. if(month==pali_month_name[i_month_name].id){
  1183. var month_name_string=pali_month_name[i_month_name].value;
  1184. var season_name_string=pali_month_name[i_month_name].season;
  1185. var season_icon_string=pali_month_name[i_month_name].season_icon;
  1186. }
  1187. }
  1188. return_string.string_0 ="<div><span class='BE_icon_span'>"+gLocal.gui.season+"</span>";
  1189. return_string.string_0+=season_icon_string+"</div>";
  1190. return_string.string_0+="<div><span class='BE_icon_span'>"+gLocal.gui.month+"</span>";
  1191. return_string.string_0+=month_name_string+"</div>";
  1192. return_string.string_1=season_name_string+"-utu. "
  1193. return_string.string_1+="asmiṃ utumhi "+month_name_string+"-māsassa ";
  1194. var day_object=uposatha_calculator(month,day);
  1195. for(i_day_name in pali_date_name){
  1196. if(day_object.day==pali_date_name[i_day_name].id){
  1197. day_name_string=pali_date_name[i_day_name].value;
  1198. var day_num_string=day_object.day
  1199. }
  1200. }
  1201. var pakkha_name_string=day_object.pakkha+"-pakkhe "+day_name_string;
  1202. return_string.string_0+="<div><span class='BE_icon_span'>"+gLocal.gui.pakkha+"</span>";
  1203. return_string.string_0+=day_object.pakkha_icon+"</div>";
  1204. return_string.string_0+="<div><span class='BE_icon_span'>"+gLocal.gui.date+"</span>";
  1205. return_string.string_0+=day_num_string+"</div>";
  1206. return_string.string_1+=pakkha_name_string+", ";
  1207. return(return_string);
  1208. }
  1209. function get_week_day_name(week_day){
  1210. var week_day_string=new Object;
  1211. for(i_week in pali_week_day_name){
  1212. if(week_day==pali_week_day_name[i_week].id){
  1213. week_day_string.string_0=pali_week_day_name[i_week].value
  1214. week_day_string.string_1=pali_week_day_name[i_week].value
  1215. }
  1216. }
  1217. week_day_string.string_0="<div><span class='BE_icon_span'>"+gLocal.gui.week_day+"</span>"+week_day_string.string_0+"</div>";
  1218. week_day_string.string_1+="-varamidan’ti daṭṭhabbaṃ."
  1219. return(week_day_string);
  1220. }
  1221. function set_display(hide_id,show_id){
  1222. $("#"+show_id).show();
  1223. $("#"+hide_id).hide();
  1224. }
  1225. function confirm_position(hide_id,show_id,position){
  1226. $("#"+show_id).show();
  1227. $("#"+hide_id).hide();
  1228. var LT_str="";
  1229. if($("#LT_"+position+"_°")[0].value!=0){
  1230. LT_str+=$("#LT_"+position+"_°")[0].value+"°";
  1231. }
  1232. if($("#LT_"+position+"_’")[0].value!=0){
  1233. LT_str+=$("#LT_"+position+"_’")[0].value+"’";
  1234. }
  1235. if($("#LT_"+position+"_”")[0].value!=0){
  1236. LT_str+=$("#LT_"+position+"_”")[0].value+"”";
  1237. }
  1238. if(LT_str!=""){
  1239. if($("#"+position+"_WE")[0].value=="+"){
  1240. LT_str+="E";
  1241. }
  1242. else{
  1243. LT_str+="W";
  1244. }
  1245. }
  1246. var AT_str="";
  1247. if($("#AT_"+position+"_°")[0].value!=0){
  1248. AT_str+=$("#AT_"+position+"_°")[0].value+"°";
  1249. }
  1250. if($("#AT_"+position+"_’")[0].value!=0){
  1251. AT_str+=$("#AT_"+position+"_’")[0].value+"’";
  1252. }
  1253. if($("#AT_"+position+"_”")[0].value!=0){
  1254. AT_str+=$("#AT_"+position+"_”")[0].value+"”";
  1255. }
  1256. if(AT_str!=""){
  1257. if($("#"+position+"_NS")[0].value=="+"){
  1258. AT_str+="N";
  1259. }
  1260. else{
  1261. AT_str+="S";
  1262. }
  1263. }
  1264. $("#"+position+"_position_string").html(LT_str+" "+AT_str);
  1265. }
  1266. function getLocation(){//自动定位
  1267. if(navigator.geolocation){
  1268. navigator.geolocation.getCurrentPosition(showPosition,showError);
  1269. }
  1270. else{
  1271. $("#selected_position_string").html("Geolocation is not supported by this browser.");
  1272. }
  1273. }
  1274. function showPosition(position){
  1275. alert("get cordinate success");
  1276. g_coordinate_this.AT=position.coords.latitude;
  1277. g_coordinate_this.LT=position.coords.longitude;
  1278. if(g_coordinate_this.AT>=0){
  1279. var AT_string=angle_trans(g_coordinate_this.AT)+"N";
  1280. }
  1281. else{
  1282. var AT_string=angle_trans(g_coordinate_this.AT)+"S";
  1283. }
  1284. if(g_coordinate_this.LT>=0){
  1285. var LT_string=angle_trans(g_coordinate_this.LT)+"E";
  1286. }
  1287. else{
  1288. var LT_string=angle_trans(g_coordinate_this.LT)+"W";
  1289. }
  1290. $("#selected_position_string").html(AT_string+" "+LT_string);
  1291. }
  1292. function showError(error){
  1293. switch(error.code) {
  1294. case error.PERMISSION_DENIED:
  1295. alert("定位失败,用户拒绝请求地理定位");
  1296. break;
  1297. case error.POSITION_UNAVAILABLE:
  1298. alert("定位失败,位置信息是不可用");
  1299. break;
  1300. case error.TIMEOUT:
  1301. alert("定位失败,请求获取用户位置超时");
  1302. break;
  1303. case error.UNKNOWN_ERROR:
  1304. alert("定位失败,定位系统失效");
  1305. break;
  1306. }
  1307. }
  1308. function confirm(){
  1309. confirm_position("position_input","position_change","selected")
  1310. var select_day_string=new Array();
  1311. select_day_string=$('#cur_day_string')[0].innerText.split('-');
  1312. 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)
  1313. }
  1314. dawn_noon_display();
  1315. function air_confirm(place){
  1316. confirm_position(place+"_position_input",place+"_position_result",place);
  1317. var coordinate= get_coordinate_num(place);
  1318. var air_date=$("#"+place+"_date")[0].value;
  1319. var air_time=$("#"+place+"_time")[0].value;
  1320. $("#"+place+"_position_string")[0].innerText+=" "+air_date+" "+air_time;
  1321. $("#air_time_string").load("calendar_data.php?atitude="+coordinate.AT+"&longitude="+coordinate.LT+"&date="+air_date);
  1322. var air_noon_time=new Date();
  1323. air_noon_time.setTime($("#air_time_string")[0].innerText.split('-')[1]);
  1324. $("#"+place+"_position_string")[0].innerText+=gLocal.gui.noon_time+set_time_string(air_noon_time);
  1325. }
  1326. function computeSunRiseSunSet(Latitude, Longitude, TimeZone) {
  1327. var curTime = new Date();
  1328. // 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
  1329. var retVal = new Object();
  1330. var PI = Math.PI;
  1331. var DR = PI / 180;
  1332. var RD = 1 / DR;
  1333. var B5 = Latitude;
  1334. var L5 = Longitude;
  1335. var H = -1 * (curTime.getTimezoneOffset() / 60 * -1); // Local timezone
  1336. // Overriding TimeZone to standardize on UTC
  1337. // H = 0;
  1338. var M = curTime.getMonth() + 1;
  1339. var D = curTime.getDate();
  1340. B5 = DR * B5;
  1341. var N = parseInt(275 * M / 9) - 2 * parseInt((M + 9) / 12) + D - 30;
  1342. var L0 = 4.8771 + .0172 * (N + .5 - L5 / 360);
  1343. var C = .03342 * Math.sin(L0 + 1.345);
  1344. var C2 = RD * (Math.atan(Math.tan(L0 + C)) - Math.atan(.9175 * Math.tan(L0 + C)) - C);
  1345. var SD = .3978 * Math.sin(L0 + C);
  1346. var CD = Math.sqrt(1 - SD * SD);
  1347. var SC = (SD * Math.sin(B5) + .0145) / (Math.cos(B5) * CD);
  1348. if (Math.abs(SC) <= 1) {
  1349. var C3 = RD * Math.atan(SC / Math.sqrt(1 - SC * SC));
  1350. var R1 = 6 - H - (L5 + C2 + C3) / 15;
  1351. var HR = parseInt(R1);
  1352. var MR = parseInt((R1 - HR) * 60);
  1353. retVal.SunRise = parseTime(HR + ":" + MR);
  1354. var TargetTimezoneOffset = (TimeZone * 60 * 60 * 1000) + (retVal.SunRise.getTimezoneOffset() * 60 * 1000);
  1355. var transformedSunRise = new Date(retVal.SunRise.getTime() + TargetTimezoneOffset);
  1356. var strSunRise = "日出" + transformedSunRise.getHours() + ":" + (transformedSunRise.getMinutes() < 10 ? "0" + transformedSunRise.getMinutes() : transformedSunRise.getMinutes());
  1357. var S1 = 18 - H - (L5 + C2 - C3) / 15;
  1358. var HS = parseInt(S1);
  1359. var MS = parseInt((S1 - HS) * 60);
  1360. retVal.SunSet = parseTime(HS + ":" + MS);
  1361. var transformedSunSet = new Date(retVal.SunSet.getTime() + TargetTimezoneOffset);
  1362. var strSunSet = "日落" + transformedSunSet.getHours() + ":" + (transformedSunSet.getMinutes() < 10 ? "0" + transformedSunSet.getMinutes() : transformedSunSet.getMinutes());
  1363. retVal.Noon = new Date((retVal.SunRise.getTime() + retVal.SunSet.getTime()) / 2);
  1364. var transformedNoon = new Date(retVal.Noon.getTime() + TargetTimezoneOffset);
  1365. var strNoon = "正午" + transformedNoon.getHours() + ":" + (transformedNoon.getMinutes() < 10 ? "0" + transformedNoon.getMinutes() : transformedNoon.getMinutes());
  1366. }
  1367. else {
  1368. if (SC > 1) {
  1369. // str="Sun up all day";
  1370. strSunRise = ".";
  1371. strNoon = ".";
  1372. strSunSet = ".";
  1373. var tDate = new Date();
  1374. // Set Sunset to be in the future ...
  1375. retVal.SunSet = new Date(tDate.getFullYear() + 1, tDate.getMonth(), tDate.getDay(), tDate.getHours());
  1376. // Set Sunrise to be in the past ...
  1377. retVal.SunRise = new Date(tDate.getFullYear() - 1, tDate.getMonth(), tDate.getDay(), tDate.getHours() - 1);
  1378. }
  1379. if (SC < -1) {
  1380. // str="Sun down all day";
  1381. strSunRise = ".";
  1382. strNoon = ".";
  1383. strSunSet = ".";
  1384. // Set Sunrise and Sunset to be in the future ...
  1385. retVal.SunRise = new Date(tDate.getFullYear() + 1, tDate.getMonth(), tDate.getDay(), tDate.getHours());
  1386. retVal.SunSet = new Date(tDate.getFullYear() + 1, tDate.getMonth(), tDate.getDay(), tDate.getHours());
  1387. }
  1388. }
  1389. retVal.strSunRise = strSunRise;
  1390. retVal.strNoon = strNoon;
  1391. retVal.strSunSet = strSunSet;
  1392. retVal.str = strSunRise + ' | ' + strNoon + ' | ' + strSunSet;
  1393. return retVal;
  1394. }
  1395. ////////////////////////////////////////////////////////////////////////////////
  1396. //
  1397. // parseTime(string aTime) - takes a string of time in the format HH:MM:SS
  1398. // and returns Javascript Date Object
  1399. //
  1400. ////////////////////////////////////////////////////////////////////////////////
  1401. function parseTime(aTime) {
  1402. var aDateTimeObject = 'none';
  1403. if (aTime !== undefined && aTime.length) {
  1404. aDateTimeObject = GMTTime();
  1405. try {
  1406. var theHour = parseInt(aTime.split(':')[0]);
  1407. var theMinutes = parseInt(aTime.split(':')[1]);
  1408. aDateTimeObject.setHours(theHour);
  1409. aDateTimeObject.setMinutes(theMinutes);
  1410. }
  1411. catch (ex) {
  1412. }
  1413. }
  1414. return aDateTimeObject;
  1415. }
  1416. ////////////////////////////////////////////////////////////////////////////////
  1417. //
  1418. // GMTTime() - returns time adjusted to GMT (Universal Time)
  1419. //
  1420. ////////////////////////////////////////////////////////////////////////////////
  1421. function GMTTime() {
  1422. var aDate = new Date();
  1423. var aDateAdjustedToGMTInMS = aDate.getTime() + (aDate.getTimezoneOffset() * 60 * 1000);
  1424. return (new Date(aDateAdjustedToGMTInMS));
  1425. }
  1426. </script>