Modul:Kalénder Bali
Dokuméntasi antuk modul puniki prasida kakardi ring Modul:Kalénder Bali/doc
-- sumber:https://excelinaja.wordpress.com/2017/09/29/belajar-membuat-kalender-bali-dengan-excel/
-- acuan tanggal 26/06/2016
local p = {}
local function makeWikilink(link, display)
if display then
return string.format('[[%s|%s]]', link, display)
else
return string.format('[[%s]]', link)
end
end
function p.main()
local dateStuff = p.getDateStuff()
local dayStrings = p.makeDayStrings(dateStuff)
return p.export(dayStrings, dateStuff)
end
function p.getDateStuff()
-- Gets date data.
local dateStuff = {}
local lang = mw.language.getContentLanguage()
--Year
local year = lang:formatDate('Y')
year = tonumber(year)
dateStuff.year = year
-- Month
local month = lang:formatDate('F')
dateStuff.month = month
-- Month and year
local monthAndYear = lang:formatDate('F Y')
local firstOfMonth = lang:formatDate('01-m-Y')
dateStuff.monthAndYear = monthAndYear
-- Previous month and year
dateStuff.previousMonthAndYear = lang:formatDate('F Y', firstOfMonth .. ' -1 month')
-- Next month and year
dateStuff.nextMonthAndYear = lang:formatDate('F Y', firstOfMonth .. ' +1 month')
-- Day
local day = lang:formatDate('j')
day = tonumber(day)
dateStuff.day = day
-- Days in month
local daysInMonth = lang:formatDate('j', firstOfMonth .. ' +1 month -1 day')
daysInMonth = tonumber(daysInMonth)
dateStuff.daysInMonth = daysInMonth
-- Weekday of the first day of the month
local firstWeekday = lang:formatDate('w', firstOfMonth) -- Sunday = 0, Saturday = 6
firstWeekday = tonumber(firstWeekday)
firstWeekday = firstWeekday + 1 -- Make compatible with Lua tables. Sunday = 1, Saturday = 7.
dateStuff.firstWeekday = firstWeekday
return dateStuff
end
-- TABEL WEWARAN DAN PALINTANGAN
local eka_info = {
{ 'Luang', 1 },
}
local dwi_info = {
{ 'Manga', 5 },
{ 'Pepet', 4 },
}
local tri_info = {
{ 'Pasah', 9 },
{ 'Beteng', 4 },
{ 'Kajeng', 7 },
}
local catur_info = {
{ 'Sri', 6 },
{ 'Laba', 5 },
{ 'Jaya', 1 },
{ 'Menala', 8 },
}
local panca_info = {
{ 'Umanis', 5 },
{ 'Paing', 9 },
{ 'Pon', 7 },
{ 'Wagé', 4 },
{ 'Kliwon', 8 },
}
local sad_info = {
{ 'Tungleh', 7 },
{ 'Aryang', 6 },
{ 'Urukung', 5 },
{ 'Paniron', 8 },
{ 'Was', 9 },
{ 'Maulu', 3 },
}
local sapta_info = {
[0] = { 'Red', 'Redité', 5 },
{ 'Som', 'Soma', 4 },
{ 'Ang', 'Anggara', 3 },
{ 'Bud', 'Buda', 7 },
{ 'Wre', 'Wrespati', 8 },
{ 'Suk', 'Sukra', 6 },
{ 'San', 'Saniscara', 9 },
}
local asta_info = {
{ 'Sri', 6 },
{ 'Indra', 5 },
{ 'Guru', 8 },
{ 'Yama', 9 },
{ 'Ludra', 3 },
{ 'Brahma', 7 },
{ 'Kala', 1 },
{ 'Uma', 4 },
}
local sanga_info = {
{ 'Dangu', 5 },
{ 'Jangur', 8 },
{ 'Gigis', 9 },
{ 'Nohan', 3 },
{ 'Ogan', 7 },
{ 'Erangan', 1 },
{ 'Urungan', 4 },
{ 'Tulus', 6 },
{ 'Dadi', 8 },
}
local dasa_info = {
{ 'Pandita', 5 },
{ 'Pati', 7 },
{ 'Suka', 10 },
{ 'Duka', 4 },
{ 'Sri', 6 },
{ 'Manuh', 2 },
{ 'Manusa', 3 },
{ 'Raja', 8 },
{ 'Dewa', 9 },
{ 'Raksasa', 1 },
}
local watek_madia_info = {
{ 'Gajah' },
{ 'Watu' },
{ 'Bhuta' },
{ 'Suku' },
{ 'Wong' },
}
local watek_alit_info = {
{ 'Uler' },
{ 'Gajah' },
{ 'Lembu' },
{ 'Lintah' },
}
local wuku_info = {
{ 'Sinta', 7 },
{ 'Landep', 1 },
{ 'Ukir', 4 },
{ 'Kulantir', 6 },
{ 'Taulu', 5 },
{ 'Gumbreg', 8 },
{ 'Wariga', 9 },
{ 'Warigadean', 3 },
{ 'Julungwangi', 7 },
{ 'Sungsang', 1 },
{ 'Dunggulan', 4 },
{ 'Kuningan', 6 },
{ 'Langkir', 5 },
{ 'Medangsia', 8 },
{ 'Pujut', 9 },
{ 'Pahang', 3 },
{ 'Krulut', 7 },
{ 'Merakih', 1 },
{ 'Tambir', 4 },
{ 'Medangkungan', 6 },
{ 'Matal', 5 },
{ 'Uye', 8 },
{ 'Menail', 9 },
{ 'Prangbakat', 3 },
{ 'Bala', 7 },
{ 'Ugu', 1 },
{ 'Wayang', 4 },
{ 'Klawu', 6 },
{ 'Dukut', 5 },
{ 'Watugunung', 8 },
}
local ingkel_info = {
{ 'Wong' },
{ 'Sato' },
{ 'Mina' },
{ 'Manuk' },
{ 'Taru' },
{ 'Buku' },
}
local jejepan_info = {
{ 'Mina' },
{ 'Taru' },
{ 'Sato' },
{ 'Patra' },
{ 'Wong' },
{ 'Paksi' },
}
local lintang_info = {
{ 'Gajah' },
{ 'Kiriman' },
{ 'Jongsarad' },
{ 'Tiwa tiwa' },
{ 'Sangka tikel' },
{ 'Bubu bolong' },
{ 'Sungenge' },
{ 'Uluku' },
{ 'Pedati' },
{ 'Kuda' },
{ 'Gajah Mina' },
{ 'Bade' },
{ 'Magelut' },
{ 'Peglangan' },
{ 'Kala sungsang' },
{ 'Kukus' },
{ 'Asu' },
{ 'Kartika' },
{ 'Naga' },
{ 'Banyak angrem' },
{ 'Ru' },
{ 'Patrem' },
{ 'Lembu' },
{ 'Sidamalung' },
{ 'Tangis' },
{ 'Salah ukur' },
{ 'Prau pegat' },
{ 'Puwuh atarung' },
{ 'Lawean' },
{ 'Kelapa' },
{ 'Yuyu' },
{ 'Lumbung' },
{ 'Kumba' },
{ 'Udang' },
{ 'Begong' },
}
local pancasuda_info = {
{ 'Wisesa segara' },
{ 'Tunggak semi' },
{ 'Satrya wibawa' },
{ 'Sumur sinaba' },
{ 'Bumi kapetak' },
{ 'Satrya wirang' },
{ 'Lebu ketiup angin' },
}
local bulan_masehi = {
{ 'Jan', 'Januari' },
{ 'Feb', 'Pébruari' },
{ 'Mar', 'Maret' },
{ 'Apr', 'April' },
{ 'Mei', 'Méi' },
{ 'Jun', 'Juni' },
{ 'Jul', 'Juli' },
{ 'Agu', 'Agustus' },
{ 'Sep', 'Séptémber' },
{ 'Okt', 'Oktober' },
{ 'Nov', 'Nopémber' },
{ 'Des', 'Désémber' },
}
-- panomoran
local function aran_ka_nomor(text, translate)
if type(text) == 'string' then
if string.find(text, " ", 1, true) then
text = text:gsub(" ", "_")
end
return translate[text:lower()]
end
end
local function ekawara(text)
return aran_ka_nomor(text, {
luang = 1,
})
end
local function dwiwara(text)
return aran_ka_nomor(text, {
manga = 1,
pepet = 2,
})
end
local function triwara(text)
return aran_ka_nomor(text, {
pasah = 1,
beteng = 2,
kajeng = 3,
})
end
local function caturwara(text)
return aran_ka_nomor(text, {
sri = 1,
laba = 2,
jaya = 3,
menala = 4,
})
end
local function pancawara(text)
return aran_ka_nomor(text, {
umanis = 1,
paing = 2,
pon = 3,
wage = 4,
kliwon = 5,
})
end
local function sadwara(text)
return aran_ka_nomor(text, {
tungleh = 1,
aryang = 2,
urukung = 3,
paniron = 4,
was = 5,
maulu = 6,
})
end
local function saptawara(text)
return aran_ka_nomor(text, {
sun = 0, sunday = 0, red = 0, redite = 0,
mon = 1, monday = 1, som = 1, soma = 1,
tue = 2, tuesday = 2, ang = 2, anggara = 2,
wed = 3, wednesday = 3, bud = 3, buda = 3,
thu = 4, thursday = 4, wre = 4, wrespati = 4,
fri = 5, friday = 5, suk = 5, sukra = 5,
sat = 6, saturday = 6, san = 6, saniscara = 6,
})
end
local function astawara(text)
return aran_ka_nomor(text, {
sri = 1,
indra = 2,
guru = 3,
yama = 4,
ludra = 5,
brahma = 6,
kala = 7,
uma = 8,
})
end
local function sangawara(text)
return aran_ka_nomor(text, {
dangu = 1,
jangur = 2,
gigis = 3,
nohan = 4,
ogan = 5,
erangan = 6,
urungan = 7,
tulus = 8,
dadi = 9,
})
end
local function dasawara(text)
return aran_ka_nomor(text, {
pandita = 1,
pati = 2,
suka = 3,
duka = 4,
sri = 5,
manuh = 6,
manusa = 7,
raja = 8,
dewa = 9,
raksasa = 10,
})
end
local function watek_alit(text)
return aran_ka_nomor(text, {
sri = 1,
indra = 2,
guru = 3,
yama = 4,
ludra = 5,
brahma = 6,
kala = 7,
uma = 8,
})
end
local function watekalit(text)
return aran_ka_nomor(text, {
uler = 1,
gajah = 2,
lembu = 3,
lintah = 4,
})
end
local function watekmadia(text)
return aran_ka_nomor(text, {
gajah = 1,
watu = 2,
bhuta = 3,
suku = 4,
wong = 5,
})
end
local function watek_ingkel(text)
return aran_ka_nomor(text, {
wong = 1,
sato = 2,
mina = 3,
manuk = 4,
taru = 5,
buku = 6,
})
end
local function watek_jejepan(text)
return aran_ka_nomor(text, {
mina = 1,
taru = 2,
sato = 3,
patra = 4,
wong = 5,
paksi = 6,
})
end
local function wuku_lintang(text)
return aran_ka_nomor(text, {
sinta = 1, gajah = 1,
landep = 2, kiriman = 2,
ukir = 3, jongsarad = 3,
kulantir = 4, tiwa_tiwa = 4,
taulu = 5, sangka_tikel = 5,
gumbreg = 6, bubu_bolong = 6,
wariga = 7, sungenge = 7,
warigadean = 8, uluku = 8,
julungwangi = 9, pedati = 9,
sungsang = 10, kuda = 10,
dunggulan = 11, gajah_mina = 11,
kuningan = 12, bade = 12,
langkir = 13, magelut = 13,
medangsia = 14, peglangan = 14,
pujut = 15, kala_sungsang = 15,
pahang = 16, kukus = 16,
krulut = 17, asu = 17,
merakih = 18, kartika = 18,
tambir = 19, naga = 19,
medangkungan = 20, banyak_angrem = 20,
matal = 21, ru = 21,
uye = 22, patrem = 22,
menail = 23, lembu = 23,
prangbakat = 24, sidamalung = 24,
bala = 25, tangis = 25,
ugu = 26, salah_ukur = 26,
wayang = 27, prau_pegat = 27,
klawu = 28, puwuh_atarung = 28,
dukut = 29, lawean = 29,
watugunung = 30, kelapa = 30,
yuyu = 31,
lumbung = 32,
kumba = 33,
udang = 34,
begong = 35,
})
end
local function bulan_nomor(text)
return aran_ka_nomor(text, {
jan = 1, january = 1, januari = 1,
feb = 2, february = 2, februari = 2,
mar = 3, march = 3, maret = 3,
apr = 4, april = 4,
may = 5, mei = 5,
jun = 6, june = 6, juni = 6,
jul = 7, july = 7, juli = 7,
aug = 8, august = 8, agu = 8, agt = 8, agustus = 8,
sep = 9, september = 9, sept = 9,
oct = 10, october = 10, okt = 10, oktober = 10,
nov = 11, november = 11,
dec = 12, december = 12, des = 12, desember = 12,
})
end
-- PAITUNGAN NEPTU MIWAH SANE LIYANAN
-- itung selisih patokan
local function call_diff()
local reference = os.time{day=26, year=2016, month=6}
local daysfrom = os.difftime(os.time(), reference) / (24 * 60 * 60) -- seconds in a day
return daysfrom
end
-- itung neptu saking urip pancawara+saptawara
local function neptu(panca, sapta)
return panca + sapta
end
-- SET
-- rereh ekawara saking gangsal genep akeh neptu
local function setEkawara(neptu)
if neptu % 2 == 1 then
return 1
end
return 0
end
-- rereh dwiwara saking gangsal genep akeh neptu sane katungkalikang
local function setDwiwara(neptu)
if neptu % 2 == 1 then
return 2
end
return 1
end
-- rereh triwara saking patokan miwah kawewehin antuk nampih warsa
local function setTriwara()
local daysfrom = call_diff()
return math.floor(daysfrom)%3+1
end
-- rereh caturwara saking patokan kawewehin antuk nampih warsa lan ring dina 71-73 punika Jaya
local function setCaturwara()
local daysfrom = call_diff() % 210
if daysfrom > 70 and daysfrom < 74 then
return 1
else
return math.floor(daysfrom) % 4 + 1
end
end
-- rereh pancawara saking patokan kawewehin antuk nampih warsa
local function setPancawara()
local daysfrom = call_diff() % 210
return math.floor(daysfrom+1)%5+1
end
-- rereh sadwara saking patokan kawewehin antuk nampih warsa
local function setSadwara()
local daysfrom = call_diff() % 210
return math.floor(daysfrom)%6+1
end
-- rereh astawara saking patokan kawewehin antuk nampih warsa
local function setAstawara()
local daysfrom = call_diff() % 210
if daysfrom > 70 and daysfrom < 74 then
return 7
else
return math.floor(daysfrom) % 8 + 1
end
end
-- rereh sangawara saking patokan kawewehin antuk nampih warsa (kakirangain 3 mawinan sampun kaangen olih Dadi < 4)
local function setSangawara()
local daysfrom = call_diff() % 210
if daysfrom < 4 then
return 1
else
return math.floor(daysfrom-3) % 9 + 1
end
end
-- rereh dasawara saking modulo neptu
local function setDasawara(neptu)
return neptu % 10 + 1
end
-- rereh watek madia saking modulo neptu
local function setMadya(neptu)
return (neptu-1) % 5 + 1
end
-- rereh watek alit saking modulo neptu
local function setAlit(neptu)
return (neptu-1) % 4 + 1
end
-- rereh ingkel jejepan saking patokan kawewehin antuk nampih warsa
local function setJejepan_ingkel()
local daysfrom = math.floor(call_diff() % 210)
return daysfrom % 6 + 1
end
-- rereh lintang saking patokan kawewehin antuk nampih warsa
local function setLintang()
local daysfrom = math.floor(call_diff() % 210)
return daysfrom % 35 + 1
end
-- rereh astawara saking patokan kawewehin antuk nampih warsa
local function setWuku()
local daysfrom = math.floor(call_diff() % 210)
if os.date("%Y") >= "2020" then
return (daysfrom + 5) % 30 + 1
end
return daysfrom % 30 + 1
end
-- GET
local function getEkawara(neptu)
return eka_info[setEkawara(neptu)][1]
end
local function getDwiwara(neptu)
return dwi_info[setDwiwara(neptu)][1]
end
local function getTriwara()
return tri_info[setTriwara()][1]
end
local function getCaturwara()
return catur_info[setCaturwara()][1]
end
local function getPancawara()
return panca_info[setPancawara()][1]
end
local function getSadwara()
return sad_info[setSadwara()][1]
end
local function getSaptawara()
return sapta_info[setSaptawara()][2]
end
local function getAstawara()
return asta_info[setAstawara()][1]
end
local function getSangawara()
return sanga_info[setSangawara()][1]
end
local function getDasawara(neptu)
return dasa_info[setDasawara(neptu)][1]
end
-- alih wuku miwah sane liyane
local function getWuku()
return wuku_info[setWuku()][1]
end
local function getMadya(neptu)
return watek_madya_info[setMadya(neptu)][1]
end
local function getAlit(neptu)
return watek_alit_info[setAlit(neptu)][1]
end
local function getIngkel()
return ingkel_info[setJejepan_ingkel()][1]
end
local function getWuku()
return jejepan_info[setJejepan_ingkel()][1]
end
local function getLintang()
return lintang_info[setLintang()][1]
end
-- FORMAT
local function _list_text(list, fmt)
-- Return a list of formatted strings from a list of dates.
if not type(list) == 'table' then
error('date:list:text: need "list:text()" with a colon', 2)
end
local result = { join = _list_join }
for i, date in ipairs(list) do
result[i] = date:text(fmt)
end
return result
end
-- cetak warsa
local function getDisplayYear (props)
local year_text = props.year;
local lk_prefix = props.lk_pref_y or props.lk_pref;
local lk_suffix = props.lk_suff_y or props.lk_suff;
if props.lk_y then -- if to be linked
if lk_prefix or lk_suffix then -- when prefix or suffix, [[prefix .. link .. suffix|label]]
year_text = make_wikilink ((lk_prefix or '') .. year_text .. (lk_suffix or ''), year_text);
else
year_text = make_wikilink (year_text); -- just year
end
end
return year_text;
end
-- cetak aran wewaran
local function nomor_ka_cetak(wuku, eka, dwi, tri, catur, panca, sad, sapta, asta, sanga, dasa, wam, waa, ing_jeje, lintang)
--print wuku
print ("Wuku:",wuku_info[wuku][1])
--print ekawara
if eka == 1 then
print ("Ekawara:",eka_info[eka][1])
else
print ("Ekawara: ")
end
-- print wewaran liyanan
print ("Dwiwara:",dwi_info[dwi][1])
print ("Triwara:",tri_info[tri][1])
print ("Caturwara:",catur_info[catur][1])
print ("Pancawara:",panca_info[panca][1])
print ("Sadwara:",sad_info[sad][1])
print ("Saptawara:",sapta_info[sapta][2])
print ("Astawara:",asta_info[asta][1])
print ("Sangawara:",sanga_info[sanga][1])
print ("Dasawara:",dasa_info[dasa][1])
-- print palintangan
print ("Watek madya:",watek_madia_info[wam][1])
print ("Watek alit:",watek_alit_info[waa][1])
print ("Ingkel:",ingkel_info[ing_jeje][1])
print ("Jejepan:",jejepan_info[ing_jeje][1])
print ("Lintang:",lintang_info[lintang][1])
end
--MAIN
local eka, dwi, tri, catur, panca, sad, sapta, asta, sanga, dasa
local wuku, wam, waa, ingkel, jejepan, lintang
local month, week
local value1, useDate
-- alih panca lan sapta
panca = setPancawara()
sapta = tonumber(os.date("%w"))
-- alih neptu
local urip_panca = tonumber(panca_info[panca][2])
local urip_sapta = tonumber(sapta_info[sapta][3])
local neptu= neptu(urip_panca,urip_sapta)
-- alih wara liyanan
eka = getEkawara(neptu)
dwi = getDwiwara(neptu)
tri = getTriwara()
catur = getCaturwara()
sad = getSadwara()
asta = getAstawara()
sanga = getSangawara()
dasa = getDasawara(neptu)
-- alih wuku miwah sane liyane
wuku = getWuku()
wam = getMadya(neptu)
waa = getAlit(neptu)
ing_jeje = getJejepan_ingkel()
lintang = getLintang()
-- alih masehi
month = bulan_nomor(os.date("%B"))
week = os.date("%W")+1
-- nomor_ka_cetak(wuku, eka, dwi, tri, catur, panca, sad, sapta, asta, sanga, dasa, wam, waa, ing_jeje, lintang)