Kata Baru

Tentang Pikiran, Perkataan, dan Perbuatan

Menghitung Hari Libur Keagamaan (Hindu) dengan VB Classic


Setelah pada artikel sebelumnya “Menghitung Hari Libur Keagamaan (Kristen) dengan VB Classic”, kini giliran menghitung haru libur keagamaan Hindu, yaitu hari raya Nyepi.


Buatlah sebuah module pada IDE VB6, namai dengan “basHindu”, kemudian ketikkan kode di bawah ini:

Option Explicit

Public Nyepi As Date

Public Sub Hindu(iTahun As Integer)
    Dim TA(1 To 33) As Integer
    Const cTanggal As Integer = 28
    Const cBulan As Integer = 3

    Dim intBulan As Integer
    Dim intTahun As Integer
    Dim intAM1 As Long
    Dim intKoreksiGr As Long
    Dim intH As Long
    Dim intN As Long
    Dim intI As Integer
    Dim Ma As Integer
    Dim Mb As Integer
    Dim MbMin As Integer

    Dim cDateFull As Date

    Dim Ya As Integer
    Dim Yb As Integer

    Dim x As Integer

    Dim datMa As Date
    Dim datMb As Date

    Dim datA1 As Date
    Dim datA2 As Date

    Dim lngMa As Long
    Dim lngMb As Long

    Dim intResult As Long
    Dim datResult As Date

    TA(1) = 0:    TA(2) = 30
    TA(3) = 60:    TA(4) = 89
    TA(5) = 119:    TA(6) = 148
    TA(7) = 178:    TA(8) = 207
    TA(9) = 237:    TA(10) = 266
    TA(11) = 296:    TA(12) = 325
    TA(13) = 355:    TA(14) = 384
    TA(15) = 414:    TA(16) = 443
    TA(17) = 473:    TA(18) = 502
    TA(19) = 532:    TA(20) = 562
    TA(21) = 591:    TA(22) = 621
    TA(23) = 650:    TA(24) = 680
    TA(25) = 709:    TA(26) = 739
    TA(27) = 768:    TA(28) = 798
    TA(29) = 827:    TA(30) = 857
    TA(31) = 886:    TA(32) = 916
    TA(33) = 945

    If cBulan < 3 Then
        intBulan = cBulan + 12
    Else
        intBulan = cBulan
    End If

    If intBulan < 3 Then
        intTahun = iTahun - 1
    Else
        intTahun = iTahun
    End If

    intAM1 = Int(365.25 * intTahun) + _
    Int(30.60001 * (intBulan + 1)) + cTanggal - 428

    If intAM1 < 577748 Then
        intKoreksiGr = 0
    Else
        intKoreksiGr = 2 - Int(intTahun / 100) + _
        Int(Int(intTahun / 100) / 4)
    End If

    intH = Int(365.25 * intTahun) + _
    Int(30.60001 * (intBulan + 1)) + cTanggal + _
    intKoreksiGr - 428

    intN = intH Mod 945

    If intN < 351 Then
        intI = (intN + 945) - 351
    Else
        intI = intN - 351
    End If

    For x = 1 To 33
        If TA(x) >= intI Then
            Ya = TA(x)
            Yb = TA(x - 1)
            Exit For
        End If
    Next

    datA1 = DateSerial(iTahun, 3, 31)
    datA2 = DateSerial(iTahun, 3, 2)

    Ma = Ya - intI + 1
    Mb = intI - Yb - 1

    MbMin = Mb + 1

    cDateFull = DateSerial(intTahun, intBulan, cTanggal)

    datMa = DateAdd("d", Ma - 1, cDateFull)
    datMb = DateAdd("d", -MbMin, cDateFull)

    lngMa = IIf(datMa >= datA1, 0, CLng(datMa))
    lngMb = IIf(datMb >= datA2, CLng(datMb), 0)

    intResult = lngMa + lngMb

    datResult = CDate(intResult)

    Nyepi = datResult
End Sub

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: