fbpx
วิกิพีเดีย

มอดูล:ตัวอย่างหรคุณจูเลียน

คู่มือการใช้งานมอดูล[ดู] [แก้] [ประวัติ] [ล้างแคช]

มอดูล ตัวอย่างหรคุณจูเลียน นี้ ใช้สำหรับแสดงผลตัวอย่างการคำนวณประกอบบทความ หรคุณจูเลียน และสามารถนำไปใช้ในการคำนวณหรคุณจูเลียน (หรือวันที่จูเลียน) ได้ตามปกติ (แต่ควรจะดัดแปลงแก้ไขเป็นฟังก์ชันเฉพาะหรือมอดูลเฉพาะ เพราะโค้ดในมอดูลนี้สามารถส่งค่าอื่นที่เป็นค่ามัธยันตร์ (intermediate) ระหว่างการคำนวณออกมา นอกเหนือจากค่าผลลัพธ์สุดท้าย) นอกจากนี้ยังสามารถใช้แสดงขั้นตอนในการคำนวณวันมหาสงกรานต์และวันเถลิงศกได้ด้วย

ในมอดูลนี้ประกอบด้วยฟังก์ชัน 5 ฟังก์ชัน คือ

  • calcjd คำนวณหรคุณจูเลียนของวันที่ dy เดือน mo ปี ค.ศ. yr ตามวิธีของ Doggett (1992)
  • calcjd2 ทำงานเช่นเดียวกับ calcjd แต่ใช้วิธีของ Jean Meeus
  • calcdatefromjd คำนวณวันที่จากหรคุณจูเลียนที่กำหนดให้
  • calcdatefromjd2 ทำงานเช่นเดียวกับ calcdatefromjd
  • jdnewariesandnewyear ใช้คำนวณหาวันมหาสงกรานต์และวันเถลิงศก

การใช้งาน

สำหรับฟังก์ชัน calcjd และ calcjd2 ระบุปีคริสต์ศักราช เดือน วันที่ และเลขลำดับตัวแปรที่ต้องการส่งออกตามลำดับ

{{#invoke:ตัวอย่างหรคุณจูเลียน|calcjd หรือ calcjd2|yr|mo|dy|lineno}} 

สำหรับฟังก์ชัน calcdatefromjd และ calcdatefromjd2 ระบุหรคุณ ณ เวลา 12 นาฬิกาของวันที่ต้องการ จะส่งค่าวันที่ เดือน ปี หรือค่าคำนวณอื่นออกมา

{{#invoke:ตัวอย่างหรคุณจูเลียน|calcdatefromjd หรือ calcdatefromjd2|jd|lineno}} 

สำหรับฟังก์ชัน jdnewariesandnewyear ระบุ ค.ศ. ที่ต้องการหา และเลือกโหมดว่า จะคำนวณวันมหาสงกรานต์หรือวันเถลิงศก

{{#invoke:ตัวอย่างหรคุณจูเลียน|jdnewariesandnewyear|year|mode|lineno}} 

รายละเอียดของค่า lineno ที่เหมาะสมโปรดอ่านในฟังก์ชัน

--[[ มอดูล: ตัวอย่างหรคุณจูเลียน ประโยชน์: สำหรับแสดงตัวอย่างการคำนวณในบทความ หรคุณจูเลียน และ สงกรานต์ เนื่องจากการแสดงตัวอย่างโดยคำสั่ง #expr: แก้ไขได้ยาก อ่านเข้าใจยาก มอดูลนี้ไม่ใช้ในการคำนวณหรคุณจูเลียน สำหรับเครื่องมือในการคำนวณ โปรดดู แม่แบบ:หรคุณจูเลียน  วิธีการเรียกใช้งานพึงปฏิบัติดังนี้ {{#invoke|ตัวอย่างหรคุณจูเลียน|ชื่่อฟังก์ชัน|ตัวแปรรับเข้าคั่นด้วยขีดตั้ง}}  ในมอดูลนี้มีฟัง5 ชัน 6 ฟังก์ชันด้วยกัน คือ 1. calcjd(yr,mo,dy,hr,mn,sc,lineno) หาหรคุณจูเลียน 2. calcjd2(yr,mo,dy,hr,mn,sc,lineno) 3. calcdatefromjd(jd,lineno) หาวันที่จากหรคุณจูเลียน ณ เวลา 12 นาฬิกา 4. calcdatefromhd2(jd,lineno) 5. jdnewariesandnewyear(yr,mode,lineno) หาหรคุณจูเลียน ณ วันมหาสงกรานต์ ถ้า mode = 1 หรือหาหรคุณจูเลียน ณ วันเถลิงศก ถ้า mode เป็นค่าอื่น กำหนด วันที่ dy เดือน mo ปีคริสตศักราช yr ส่วน lineno แทนลำดับของตัวแปรที่จะส่งออกไปประกอบตัวอย่าง --]] local p = {}  function p.calcjd(frame)  -- ในวิกิการระบุตัวแปรรับเข้าทุกตัวไว้ในวงเล็บเริ่มฟังก์ชันไม่สามารถทำได้ แต่ภาษาลูอาปกติรองรับ  -- การกระทำดังกล่าว เช่นเดียวกับภาษาอื่น  local yr = tonumber(frame.args[1])  local mo = tonumber(frame.args[2])  local dy = tonumber(frame.args[3])  local lineno = tonumber(frame.args[4])   local line1 = math.floor((1461 * (yr + 4800 + math.floor((mo - 14)/12)))/4)  local line2 = math.floor((367 * (mo - 2 - 12 * math.floor((mo - 14)/12)))/12)  local line3 = math.floor((3 * math.floor((yr + 4900 + math.floor((mo - 14)/12))/100))/4)  local line4 = dy - 32077  local jd = line1 + line2 - line3 + line4  local result  if lineno == 1 then  result = line1  elseif lineno == 2 then  result = line2  elseif lineno == 3 then  result = line3  elseif lineno == 4 then  result = line4  else  result = jd  end  return result end  function p.calcjd2(frame)  --[[  ดูเพิ่ม Meeus, Jean (1998). Astronomical Algorithms. Willman Bell. pp. 60–61.  --]]  local yr = tonumber(frame.args[1])  local mo = tonumber(frame.args[2])  local dy = tonumber(frame.args[3])  local lineno = tonumber(frame.args[4])   if mo<=2 then  mo = mo + 12  yr = yr - 1  end   local A = math.floor(yr/100)  local B = 2 - A + math.floor(A/4)  local jd = math.floor(365.25 * (yr + 4716)) + math.floor(30.6001 * (mo+1)) + dy + B - 1524  local result  if lineno == 1 then  result = mo  elseif lineno == 2 then  result = yr  elseif lineno == 3 then  result = A  elseif lineno == 4 then  result = B  else  result = jd  end  return result end  function p.calcdatefromjd(frame)  --[[  แปลงหรคุณจูเลียน jd ณ เวลา 12 นาฬิกา เป็นวันที่  lineno เป็นตัวเลขกำกับสำหรับระบุค่าคำนวณที่จะส่งออก เรียงตามลำดับบรรทัด  --]]  local jd = tonumber(frame.args[1])  local lineno = tonumber(frame.args[2])  local f = jd + 1401 + math.floor((math.floor((4*jd + 274277)/146097)*3)/4) -38  local e = 4*f + 3  local g = math.floor(math.fmod(e, 1461)/4)  local h = 5*g + 2  local dy = math.floor((math.fmod(h, 153))/5) + 1  local mo = math.fmod(math.floor(h/153) + 2, 12) + 1  local yr = math.floor(e/1461) - 4716 + math.floor((12 + 2 - mo)/12)  local result  if lineno == 1 then  result = f  elseif lineno == 2 then  result = e  elseif lineno == 3 then  result = g  elseif lineno == 4 then  result = h  elseif lineno == 5 then  result = dy  elseif lineno == 6 then  result = mo  else  result = yr  end   return result end   function p.calcdatefromjd2(frame)  --[[  ดูเพิ่ม Meeus, Jean (1998). Astronomical Algorithms. Willman Bell.  และโค้ดใน https://www.esrl.noaa.gov/gmd/grad/solcalc/sunrise.html  --]]  local jd = tonumber(frame.args[1])  local lineno = tonumber(frame.args[2])   local z = math.floor(jd)  local A  if z < 2299161 then  A = z;  else  local alpha = math.floor((z - 1867216.25)/36524.25)  A = z + 1 + alpha - math.floor(alpha/4)  end   local B = A + 1524  local C = math.floor((B - 122.1)/365.25)  local D = math.floor(365.25 * C)  local E = math.floor((B - D)/30.6001)   local dy = B - D - math.floor(30.6001 * E)   local mo  if E < 14 then  mo = E - 1  else  mo = E - 13  end   local yr  if mo > 2 then  yr = C - 4716  else  yr = C - 4715  end   local result  if lineno == 1 then  result = z  elseif lineno == 2 then  result = A  elseif lineno == 3 then  result = B  elseif lineno == 4 then  result = C  elseif lineno == 5 then  result = D  elseif lineno == 6 then  result = E  elseif lineno == 7 then  result = dy  elseif lineno == 8 then  result = mo  else  result = yr  end   return result end  function p.jdnewariesandnewyear(frame)  --[[  คำนวณหรคุณ ณ เวลาสงกรานต์เสด็จ ของปี จ.ศ. y - 638 เมื่อ y เป็น ค.ศ.  --]]  yr = tonumber(frame.args[1])  mode = tonumber(frame.args[2])  lineno = tonumber(frame.args[3])  local sd0, sd, jd0, jd  if mode == 1 then  sd0 = ((yr-638)*292207-1359)/800  else  sd0 = ((yr-638)*292207+373)/800  end   jd0 = sd0 + 1954167.5  -- เศษเวลา  local timefrac1 = jd0 - math.floor(jd0)   if timefrac1 >= 0.5 then  -- ทศนิยมของหรคุณจูเลียน เถิน 0.5 เป็นวันใหม่ทางสุริยคติ ต้องลบออกเสีย 0.5 ก่อนคิดเวลา  timefrac2 = timefrac1 - 0.5  jd = math.floor(jd0) + 1  else  -- ทศนิยมน้อยกว่า 0.5 เลยเที่ยงวันมา ต้องเอา 0.5 บวกก่อนคิดเวลา  timefrac2 = timefrac1 + 0.5  jd = math.floor(jd0)  end   local hr = math.floor(timefrac2*24)  local rem = timefrac2*24 - hr  local mn = math.floor(rem*60)  local rem2 = rem*60 - mn  local sc = math.floor(rem2*60)  local rem3 = rem2*60 - sc  local result  if lineno == 1 then  result = sd0  elseif lineno == 2 then  result = jd0  elseif lineno == 3 then  result = sd  elseif lineno == 4 then  result = jd  elseif lineno == 5 then  result = timefrac1  elseif lineno == 6 then  result = timefrac2  elseif lineno == 7 then  result = hr  elseif lineno ==8 then  result = rem  elseif lineno == 9 then  result = mn  elseif lineno == 10 then  result = rem2  elseif lineno == 11 then  result = sc  else  result = rem3  end  return result end  return p 

มอด, วอย, างหรค, ณจ, เล, ยน, อการใช, งานมอด, แก, ประว, างแคช, this, module, rated, ready, general, reached, mature, form, thought, free, ready, wherever, appropriate, ready, mention, help, pages, other, wikipedia, resources, option, users, learn, reduce, serve. khumuxkarichnganmxdul du aek prawti langaekhch This module is rated as ready for general use It has reached a mature form and is thought to be bug free and ready for use wherever appropriate It is ready to mention on help pages and other Wikipedia resources as an option for new users to learn To reduce server load and bad output it should be improved by sandbox testing rather than repeated trial and error editing mxdul twxyanghrkhuncueliyn ni ichsahrbaesdngphltwxyangkarkhanwnprakxbbthkhwam hrkhuncueliyn aelasamarthnaipichinkarkhanwnhrkhuncueliyn hruxwnthicueliyn idtampkti aetkhwrcaddaeplngaekikhepnfngkchnechphaahruxmxdulechphaa ephraaokhdinmxdulnisamarthsngkhaxunthiepnkhamthyntr intermediate rahwangkarkhanwnxxkma nxkehnuxcakkhaphllphthsudthay nxkcakniyngsamarthichaesdngkhntxninkarkhanwnwnmhasngkrantaelawnethlingskiddwyinmxdulniprakxbdwyfngkchn 5 fngkchn khux calcjd khanwnhrkhuncueliynkhxngwnthi dy eduxn mo pi kh s yr tamwithikhxng Doggett 1992 calcjd2 thanganechnediywkb calcjd aetichwithikhxng Jean Meeus calcdatefromjd khanwnwnthicakhrkhuncueliynthikahndih calcdatefromjd2 thanganechnediywkb calcdatefromjd jdnewariesandnewyear ichkhanwnhawnmhasngkrantaelawnethlingskkarichngan aekikh sahrbfngkchn calcjd aela calcjd2 rabupikhristskrach eduxn wnthi aelaelkhladbtwaeprthitxngkarsngxxktamladb invoke twxyanghrkhuncueliyn calcjd hrux calcjd2 yr mo dy lineno sahrbfngkchn calcdatefromjd aela calcdatefromjd2 rabuhrkhun n ewla 12 nalikakhxngwnthitxngkar casngkhawnthi eduxn pi hruxkhakhanwnxunxxkma invoke twxyanghrkhuncueliyn calcdatefromjd hrux calcdatefromjd2 jd lineno sahrbfngkchn jdnewariesandnewyear rabu kh s thitxngkarha aelaeluxkohmdwa cakhanwnwnmhasngkranthruxwnethlingsk invoke twxyanghrkhuncueliyn jdnewariesandnewyear year mode lineno raylaexiydkhxngkha lineno thiehmaasmoprdxaninfngkchnkhumuxkarichnganthipraktdanbnnidungmacak mxdul twxyanghrkhuncueliyn doc aek prawti phuekhiynsamarththakarthdlxngidthikrabathray srang khdlxk aelachudthdsxb srang khxngmxdulni hnayxykhxngmxdulni mxdul twxyanghrkhuncueliyn praoychn sahrbaesdngtwxyangkarkhanwninbthkhwam hrkhuncueliyn aela sngkrant enuxngcakkaraesdngtwxyangodykhasng expr aekikhidyak xanekhaicyak mxdulniimichinkarkhanwnhrkhuncueliyn sahrbekhruxngmuxinkarkhanwn oprddu aemaebb hrkhuncueliyn withikareriykichnganphungptibtidngni invoke twxyanghrkhuncueliyn chuxfngkchn twaeprrbekhakhndwykhidtng inmxdulnimifng5 chn 6 fngkchndwykn khux 1 calcjd yr mo dy hr mn sc lineno hahrkhuncueliyn 2 calcjd2 yr mo dy hr mn sc lineno 3 calcdatefromjd jd lineno hawnthicakhrkhuncueliyn n ewla 12 nalika 4 calcdatefromhd2 jd lineno 5 jdnewariesandnewyear yr mode lineno hahrkhuncueliyn n wnmhasngkrant tha mode 1 hruxhahrkhuncueliyn n wnethlingsk tha mode epnkhaxun kahnd wnthi dy eduxn mo pikhristskrach yr swn lineno aethnladbkhxngtwaeprthicasngxxkipprakxbtwxyang local p function p calcjd frame inwikikarrabutwaeprrbekhathuktwiwinwngelberimfngkchnimsamarththaid aetphasaluxapktirxngrb karkrathadngklaw echnediywkbphasaxun local yr tonumber frame args 1 local mo tonumber frame args 2 local dy tonumber frame args 3 local lineno tonumber frame args 4 local line1 math floor 1461 yr 4800 math floor mo 14 12 4 local line2 math floor 367 mo 2 12 math floor mo 14 12 12 local line3 math floor 3 math floor yr 4900 math floor mo 14 12 100 4 local line4 dy 32077 local jd line1 line2 line3 line4 local result if lineno 1 then result line1 elseif lineno 2 then result line2 elseif lineno 3 then result line3 elseif lineno 4 then result line4 else result jd end return result end function p calcjd2 frame duephim Meeus Jean 1998 Astronomical Algorithms Willman Bell pp 60 61 local yr tonumber frame args 1 local mo tonumber frame args 2 local dy tonumber frame args 3 local lineno tonumber frame args 4 if mo lt 2 then mo mo 12 yr yr 1 end local A math floor yr 100 local B 2 A math floor A 4 local jd math floor 365 25 yr 4716 math floor 30 6001 mo 1 dy B 1524 local result if lineno 1 then result mo elseif lineno 2 then result yr elseif lineno 3 then result A elseif lineno 4 then result B else result jd end return result end function p calcdatefromjd frame aeplnghrkhuncueliyn jd n ewla 12 nalika epnwnthi lineno epntwelkhkakbsahrbrabukhakhanwnthicasngxxk eriyngtamladbbrrthd local jd tonumber frame args 1 local lineno tonumber frame args 2 local f jd 1401 math floor math floor 4 jd 274277 146097 3 4 38 local e 4 f 3 local g math floor math fmod e 1461 4 local h 5 g 2 local dy math floor math fmod h 153 5 1 local mo math fmod math floor h 153 2 12 1 local yr math floor e 1461 4716 math floor 12 2 mo 12 local result if lineno 1 then result f elseif lineno 2 then result e elseif lineno 3 then result g elseif lineno 4 then result h elseif lineno 5 then result dy elseif lineno 6 then result mo else result yr end return result end function p calcdatefromjd2 frame duephim Meeus Jean 1998 Astronomical Algorithms Willman Bell aelaokhdin https www esrl noaa gov gmd grad solcalc sunrise html local jd tonumber frame args 1 local lineno tonumber frame args 2 local z math floor jd local A if z lt 2299161 then A z else local alpha math floor z 1867216 25 36524 25 A z 1 alpha math floor alpha 4 end local B A 1524 local C math floor B 122 1 365 25 local D math floor 365 25 C local E math floor B D 30 6001 local dy B D math floor 30 6001 E local mo if E lt 14 then mo E 1 else mo E 13 end local yr if mo gt 2 then yr C 4716 else yr C 4715 end local result if lineno 1 then result z elseif lineno 2 then result A elseif lineno 3 then result B elseif lineno 4 then result C elseif lineno 5 then result D elseif lineno 6 then result E elseif lineno 7 then result dy elseif lineno 8 then result mo else result yr end return result end function p jdnewariesandnewyear frame khanwnhrkhun n ewlasngkrantesdc khxngpi c s y 638 emux y epn kh s yr tonumber frame args 1 mode tonumber frame args 2 lineno tonumber frame args 3 local sd0 sd jd0 jd if mode 1 then sd0 yr 638 292207 1359 800 else sd0 yr 638 292207 373 800 end jd0 sd0 1954167 5 essewla local timefrac1 jd0 math floor jd0 if timefrac1 gt 0 5 then thsniymkhxnghrkhuncueliyn ethin 0 5 epnwnihmthangsuriykhti txnglbxxkesiy 0 5 kxnkhidewla timefrac2 timefrac1 0 5 jd math floor jd0 1 else thsniymnxykwa 0 5 elyethiyngwnma txngexa 0 5 bwkkxnkhidewla timefrac2 timefrac1 0 5 jd math floor jd0 end local hr math floor timefrac2 24 local rem timefrac2 24 hr local mn math floor rem 60 local rem2 rem 60 mn local sc math floor rem2 60 local rem3 rem2 60 sc local result if lineno 1 then result sd0 elseif lineno 2 then result jd0 elseif lineno 3 then result sd elseif lineno 4 then result jd elseif lineno 5 then result timefrac1 elseif lineno 6 then result timefrac2 elseif lineno 7 then result hr elseif lineno 8 then result rem elseif lineno 9 then result mn elseif lineno 10 then result rem2 elseif lineno 11 then result sc else result rem3 end return result end return p ekhathungcak https th wikipedia org w index php title mxdul twxyanghrkhuncueliyn amp oldid 7372664, wikipedia, วิกิ หนังสือ, หนังสือ, ห้องสมุด,

บทความ

, อ่าน, ดาวน์โหลด, ฟรี, ดาวน์โหลดฟรี, mp3, วิดีโอ, mp4, 3gp, jpg, jpeg, gif, png, รูปภาพ, เพลง, เพลง, หนัง, หนังสือ, เกม, เกม