コード例 #1
0
def GetPrevConjunction(date, earth, forward=False):
    prevSun = 0.0
    prevMoon = 0.0
    prevDiff = 0.0
    nowSun = 0.0
    nowMoon = 0.0
    nowDiff = 0.0
    dir = 1.0 if forward else -1.0
    moon = GCMoonData.MOONDATA()

    d = GCGregorianDate(date=date)
    d.shour = 0.5
    d.tzone = 0.0
    jd = d.GetJulian()

    # set initial data for input day
    # NOTE: for grenwich
    moon.Calculate(jd, earth)
    prevSun = GCSunData.GetSunLongitude(d)
    prevMoon = moon.longitude_deg
    prevDiff = GCMath.putIn180(prevSun - prevMoon)

    for bCont in range(32):
        if forward:
            d.NextDay()
        else:
            d.PreviousDay()
        jd += dir
        moon.Calculate(jd, earth)
        nowSun = GCSunData.GetSunLongitude(d)
        nowMoon = moon.longitude_deg
        nowDiff = GCMath.putIn180(nowSun - nowMoon)

        if IsConjunction(nowMoon, nowSun, prevSun, prevMoon):
            # now it calculates actual time and zodiac of conjunction
            if prevDiff == nowDiff: return 0
            x = math.fabs(nowDiff) / math.fabs(prevDiff - nowDiff)
            if x < 0.5:
                if forward: d.PreviousDay()
                d.shour = x + 0.5
            else:
                if not forward: d.NextDay()
                d.shour = x - 0.5
            date.Set(d)
            prevSun = GCMath.putIn360(prevSun)
            nowSun = GCMath.putIn360(nowSun)
            if math.fabs(prevSun - nowSun) > 10.0:
                return GCMath.putIn180(nowSun) + (GCMath.putIn180(prevSun) -
                                                  GCMath.putIn180(nowSun)) * x
            else:
                return nowSun + (prevSun - nowSun) * x
        prevSun = nowSun
        prevMoon = nowMoon
        prevDiff = nowDiff

    return 1000.0
コード例 #2
0
    def GetNaksatraTimeRange(self, earth, fromTime, toTime):
        start = GCGregorianDate(date=self.date)
        start.shour = self.astrodata.sun.sunrise_deg / 360 + earth.tzone / 24.0

        GCNaksatra.GetNextNaksatra(earth, start, toTime)
        GCNaksatra.GetPrevNaksatra(earth, start, fromTime)
        return True
コード例 #3
0
    def GetTithiTimeRange(self, earth, fromTime, toTime):
        start = GCGregorianDate(date=self.date)
        start.shour = self.astrodata.sun.sunrise_deg / 360 + earth.tzone / 24.0

        GCTithi.GetNextTithiStart(earth, start, toTime)
        GCTithi.GetPrevTithiStart(earth, start, fromTime)

        return True
コード例 #4
0
def GetFirstDayOfYear(earth, nYear):

    a = [2, 15, 3, 1, 3, 15, 4, 1, 4, 15]
    d = GCGregorianDate()
    day = GCDayData()

    if nYear >= 1950 and nYear < 2058:
        tmp = gGaurBeg[(nYear - 1950) * 26 + 22]
        d.month = (tmp & 0x3e0) >> 5
        d.day = (tmp & 0x1f)
        d.year = nYear
        d.NextDay()
        a[0] = d.month
        a[1] = d.day

    for i in range(0, 10, 2):
        d.year = nYear
        d.month = a[i]
        d.day = a[i + 1]

        day.DayCalc(d, earth)
        masa = day.MasaCalc(d, earth)
        gy = day.nGaurabdaYear

        if masa == 11:  # visnu masa
            while True:
                # shifts date
                step = max(int(day.nTithi / 2), 1)
                for j in range(step):
                    d.PreviousDay()
                # try new time
                day.DayCalc(d, earth)
                if day.nTithi >= 28: break
            d.NextDay()
            d.tzone = earth.tzone
            d.shour = day.sun.sunrise_deg / 360.0
            return d

    d.year = -1
    d.month = -1
    d.day = -1
    d.tzone = earth.tzone
    d.shour = day.sun.sunrise_deg / 360.0

    return d
コード例 #5
0
def writeGaurabdaNextTithiXml(xml, loc, vcStart, vaStart):
    gmasa = vaStart.masa
    gpaksa = 1 if vaStart.tithi >= 15 else 0
    gtithi = vaStart.tithi % 15

    xml.write("<xml>\n")
    xml.write("\t<request name=\"Tithi\" version=\"")
    xml.write(GCStrings.getString(130))
    xml.write("\">\n")
    xml.write("\t\t<arg name=\"longitude\" val=\"")
    xml.write(str(loc.m_fLongitude))
    xml.write("\" />\n")
    xml.write("\t\t<arg name=\"latitude\" val=\"")
    xml.write(str(loc.m_fLatitude))
    xml.write("\" />\n")
    xml.write("\t\t<arg name=\"timezone\" val=\"")
    xml.write(str(loc.m_fTimezone))
    xml.write("\" />\n")
    xml.write("\t\t<arg name=\"start date\" val=\"")
    xml.write(str(vcStart))
    xml.write("\" />\n")
    xml.write("\t\t<arg name=\"masa\" val=\"")
    xml.write(str(gmasa))
    xml.write("\" />\n")
    xml.write("\t\t<arg name=\"paksa\" val=\"")
    xml.write(str(gpaksa))
    xml.write("\" />\n")
    xml.write("\t\t<arg name=\"tithi\" val=\"")
    xml.write(str(gtithi))
    xml.write("\" />\n")
    xml.write("\t</request>\n")
    xml.write("\t<result name=\"Tithi\">\n")

    earth = loc.GetEarthData()
    vcs = GCGregorianDate()
    vce = GCGregorianDate()
    sun = SUNDATA()
    A = 0
    day = GCDayData()

    today = GCGregorianDate(date=vcStart)
    today.PreviousDay()
    vcStart.SubtractDays(15)
    for A in range(0, 4):
        vcs.Set(
            GCTithi.CalcTithiEndEx(vcStart, 0, gmasa, gpaksa, gtithi, earth,
                                   vce))
        if not vcs.IsBeforeThis(today):
            oTithi = gpaksa * 15 + gtithi
            oMasa = gmasa
            oPaksa = gpaksa
            oYear = 0
            xml.write("\t<celebration\n")
            xml.write("\t\trtithi=\"")
            xml.write(GCStrings.GetTithiName(oTithi))
            xml.write("\"\n")
            xml.write("\t\trmasa=\"")
            xml.write(GCStrings.GetMasaName(oMasa))
            xml.write("\"\n")
            xml.write("\t\trpaksa=\"")
            xml.write("Gaura" if oPaksa else "Krsna")
            xml.write("\"\n")
            # test ci je ksaya
            today.Set(vcs)
            today.shour = 0.5
            sun.SunCalc(today, earth)
            sunrise = (sun.sunrise_deg + loc.m_fTimezone * 15.0) / 360
            if sunrise < vcs.shour:
                today.Set(vce)
                sun.SunCalc(today, earth)
                sunrise = (sun.sunrise_deg + loc.m_fTimezone * 15.0) / 360
                if sunrise < vce.shour:
                    # normal type
                    vcs.NextDay()
                    xml.write("\t\ttype=\"normal\"\n")
                else:
                    # ksaya
                    vcs.NextDay()
                    day.DayCalc(vcs, earth)
                    oTithi = day.nTithi
                    oPaksa = day.nPaksa
                    oMasa = day.MasaCalc(vcs, earth)
                    oYear = day.nGaurabdaYear
                    xml.write("\t\ttype=\"ksaya\"\n")
            else:
                # normal, alebo prvy den vriddhi
                today.Set(vce)
                sun.SunCalc(today, earth)
                if (sun.sunrise_deg +
                        loc.m_fTimezone * 15.0) / 360 < vce.shour:
                    # first day of vriddhi type
                    xml.write("\t\ttype=\"vriddhi\"\n")
                else:
                    # normal
                    xml.write("\t\ttype=\"normal\"\n")
            xml.write("\t\tdate=\"")
            xml.write(str(vcs))
            xml.write("\"\n")
            xml.write("\t\totithi=\"")
            xml.write(GCStrings.GetTithiName(oTithi))
            xml.write("\"\n")
            xml.write("\t\tomasa=\"")
            xml.write(GCStrings.GetMasaName(oMasa))
            xml.write("\"\n")
            xml.write("\t\topaksa=\"")
            xml.write("Gaura" if oPaksa else "Krsna")
            xml.write("\"\n")
            xml.write("\t/>\n")
            break
        else:
            vcStart.Set(vcs)
            vcs.NextDay()

    xml.write("\t</result>\n")
    xml.write("</xml>\n")
    return 1
コード例 #6
0
def writeGaurabdaTithiXml(xml, loc, vaStart, vaEnd):
    gyearA = vaStart.gyear
    gyearB = vaEnd.gyear
    gmasa = vaStart.masa
    gpaksa = 1 if vaStart.tithi >= 15 else 0
    gtithi = vaStart.tithi % 15

    if gyearB < gyearA:
        gyearB = gyearA

    xml.write("<xml>\n")
    xml.write("\t<request name=\"Tithi\" version=\"")
    xml.write(GCStrings.getString(130))
    xml.write("\">\n")
    xml.write("\t\t<arg name=\"longitude\" val=\"")
    xml.write(str(loc.m_fLongitude))
    xml.write("\" />\n")
    xml.write("\t\t<arg name=\"latitude\" val=\"")
    xml.write(str(loc.m_fLatitude))
    xml.write("\" />\n")
    xml.write("\t\t<arg name=\"timezone\" val=\"")
    xml.write(str(loc.m_fTimezone))
    xml.write("\" />\n")
    if gyearA > 1500:
        xml.write("\t\t<arg name=\"year-start\" val=\"")
        xml.write(str(gyearA))
        xml.write("\" />\n")
        xml.write("\t\t<arg name=\"year-end\" val=\"")
        xml.write(str(gyearB))
        xml.write("\" />\n")
    else:
        xml.write("\t\t<arg name=\"gaurabdayear-start\" val=\"")
        xml.write(str(gyearA))
        xml.write("\" />\n")
        xml.write("\t\t<arg name=\"gaurabdayear-end\" val=\"")
        xml.write(str(gyearB))
        xml.write("\" />\n")
    xml.write("\t\t<arg name=\"masa\" val=\"")
    xml.write(str(gmasa))
    xml.write("\" />\n")
    xml.write("\t\t<arg name=\"paksa\" val=\"")
    xml.write(str(gpaksa))
    xml.write("\" />\n")
    xml.write("\t\t<arg name=\"tithi\" val=\"")
    xml.write(str(gtithi))
    xml.write("\" />\n")
    xml.write("\t</request>\n")
    xml.write("\t<result name=\"Tithi\">\n")

    earth = loc.GetEarthData()
    vcs = GCGregorianDate()
    vce = GCGregorianDate()
    today = GCGregorianDate()
    sun = SUNDATA()
    day = GCDayData()
    A = B = 0

    if gyearA > 1500:
        A = gyearA - 1487
        B = gyearB - 1485
    else:
        A = gyearA
        B = gyearB

    for A in range(A, B + 1):
        vcs.Set(GCTithi.CalcTithiEnd(A, gmasa, gpaksa, gtithi, earth, vce))
        if gyearA > 1500:
            if (vcs.year < gyearA) or (vcs.year > gyearB):
                continue
        oTithi = gpaksa * 15 + gtithi
        oMasa = gmasa
        oPaksa = gpaksa
        oYear = 0
        xml.write("\t<celebration\n")
        xml.write("\t\trtithi=\"")
        xml.write(GCStrings.GetTithiName(oTithi))
        xml.write("\"\n")
        xml.write("\t\trmasa=\"")
        xml.write(GCStrings.GetMasaName(oMasa))
        xml.write("\"\n")
        xml.write("\t\trpaksa=\"")
        xml.write('Gaura' if oPaksa else "Krsna")
        xml.write("\"\n")
        # test ci je ksaya
        today.Set(vcs)
        today.shour = 0.5
        sun.SunCalc(today, earth)
        sunrise = (sun.sunrise_deg + loc.m_fTimezone * 15.0) / 360
        if sunrise < vcs.shour:
            today.Set(vce)
            sun.SunCalc(today, earth)
            sunrise = (sun.sunrise_deg + loc.m_fTimezone * 15.0) / 360
            if sunrise < vce.shour:
                # normal type
                vcs.NextDay()
                xml.write("\t\ttype=\"normal\"\n")
            else:
                # ksaya
                vcs.NextDay()
                day.DayCalc(vcs, earth)
                oTithi = day.nTithi
                oPaksa = day.nPaksa
                oMasa = day.MasaCalc(vcs, earth)
                oYear = day.nGaurabdaYear
                xml.write("\t\ttype=\"ksaya\"\n")
        else:
            # normal, alebo prvy den vriddhi
            today.Set(vce)
            sun.SunCalc(today, earth)
            if (sun.sunrise_deg + loc.m_fTimezone * 15.0) / 360 < vce.shour:
                # first day of vriddhi type
                xml.write("\t\ttype=\"vriddhi\"\n")
            else:
                # normal
                xml.write("\t\ttype=\"normal\"\n")
        xml.write("\t\tdate=\"")
        xml.write(str(vcs))
        xml.write("\"\n")
        xml.write("\t\totithi=\"")
        xml.write(GCStrings.GetTithiName(oTithi))
        xml.write("\"\n")
        xml.write("\t\tomasa=\"")
        xml.write(GCStrings.GetMasaName(oMasa))
        xml.write("\"\n")
        xml.write("\t\topaksa=\"")
        xml.write('Gaura' if oPaksa else 'Krsna')
        xml.write("\"\n")
        xml.write("\t/>\n")

    xml.write("\t</result>\n")
    xml.write("</xml>\n")
    return 1
コード例 #7
0
def writeXml(xml, loc, vc):
    date = GCGregorianDate()
    xml.write("<xml>\n")
    xml.write("\t<request name=\"Tithi\" version=\"")
    xml.write(GCStrings.getString(130))
    xml.write("\">\n")
    xml.write("\t\t<arg name=\"longitude\" val=\"")
    xml.write(str(loc.m_fLongitude))
    xml.write("\" />\n")
    xml.write("\t\t<arg name=\"latitude\" val=\"")
    xml.write(str(loc.m_fLatitude))
    xml.write("\" />\n")
    xml.write("\t\t<arg name=\"timezone\" val=\"")
    xml.write(str(loc.m_fTimezone))
    xml.write("\" />\n")
    xml.write("\t\t<arg name=\"startdate\" val=\"")
    xml.write(str(vc))
    xml.write("\" />\n")
    xml.write("\t</request>\n")
    xml.write("\t<result name=\"Tithi\">\n")

    d1 = GCGregorianDate()
    d2 = GCGregorianDate()
    dn = GCGregorianDate()
    dt = GCTime()
    earth = loc.GetEarthData()

    day = GCDayData()
    day.DayCalc(vc, earth)

    d = GCGregorianDate(date=vc)
    d.tzone = loc.m_fTimezone
    d.shour = day.sun.sunrise_deg / 360.0 + loc.m_fTimezone / 24.0

    GCTithi.GetPrevTithiStart(earth, d, d1)
    GCTithi.GetNextTithiStart(earth, d, d2)

    dt.SetDegTime(d1.shour * 360)
    # start tithi at t[0]
    xml.write("\t\t<tithi\n\t\t\tid=\"")
    xml.write(str(day.nTithi))
    xml.write("\"\n")
    xml.write("\t\t\tname=\"")
    xml.write(GCStrings.GetTithiName(day.nTithi))
    xml.write("\"\n")
    xml.write("\t\t\tstartdate=\"")
    xml.write(str(d1))
    xml.write("\"\n")
    xml.write("\t\t\tstarttime=\"")
    xml.write(repr(dt))
    xml.write("\"\n")

    dt.SetDegTime(d2.shour * 360)
    xml.write("\t\t\tenddate=\"")
    xml.write(str(d2))
    xml.write("\"\n")
    xml.write("\t\t\tendtime=\"")
    xml.write(repr(dt))
    xml.write("\"\n />")

    xml.write("\t</result>\n")
    xml.write("</xml>\n")

    return 1
コード例 #8
0
def CalcTithiDate(nGYear, nMasa, nPaksa, nTithi, earth):
    i = 0
    gy = 0
    d = GCGregorianDate()
    dtemp = GCGregorianDate()
    day = GCDayData()
    tithi = 0
    counter = 0
    tmp = 0

    if nGYear >= 464 and nGYear < 572:
        tmp = gGaurBeg[(nGYear - 464) * 26 + nMasa * 2 + nPaksa]
        d.month = (tmp & 0x3e0) >> 5
        d.day = (tmp & 0x1f)
        d.year = (tmp & 0xfffc00) >> 10
        d.tzone = earth.tzone
        d.NextDay()

        day.DayCalc(d, earth)
        day.nMasa = day.MasaCalc(d, earth)
        gy = day.nGaurabdaYear
    else:
        #d = GetFirstDayOfYear(earth, nGYear + 1486)
        d.day = 15
        d.month = 2 + nMasa
        d.year = nGYear + 1486
        if d.month > 12:
            d.month -= 12
            d.year += 1
        d.shour = 0.5
        d.tzone = earth.tzone

        i = 0
        while True:
            d.AddDays(13)
            day.DayCalc(d, earth)
            day.nMasa = day.MasaCalc(d, earth)
            gy = day.nGaurabdaYear
            i += 1
            if i >= 30: break
            if (day.nPaksa == nPaksa) and (day.nMasa == nMasa): break

    if i >= 30:
        d.year = d.month = d.day = -1
        return d

    # we found masa and paksa
    # now we have to find tithi
    tithi = nTithi + nPaksa * 15

    if day.nTithi == tithi:
        # loc1
        # find tithi juncts in this day and according to that times,
        # look in previous or next day for end and start of this tithi
        d.PreviousDay()
        day.DayCalc(d, earth)
        if (day.nTithi > tithi) and (day.nPaksa != nPaksa):
            d.NextDay()
        return d

    if day.nTithi < tithi:
        # do increment of date until nTithi == tithi
        #   but if nTithi > tithi
        #       then do decrement of date
        counter = 0
        while counter < 16:
            d.NextDay()
            day.DayCalc(d, earth)
            if day.nTithi == tithi:
                return d
            if (day.nTithi < tithi) and (day.nPaksa != nPaksa):
                return d
            if day.nTithi > tithi:
                return d
            counter += 1
        # somewhere is error
        d.year = d.month = d.day = 0
        return d
    else:
        # do decrement of date until nTithi <= tithi
        counter = 0
        while counter < 16:
            d.PreviousDay()
            day.DayCalc(d, earth)
            if day.nTithi == tithi:
                return d
            if (day.nTithi > tithi) and (day.nPaksa != nPaksa):
                d.NextDay()
                return d
            if day.nTithi < tithi:
                d.NextDay()
                return d
            counter += 1
        # somewhere is error
        d.year = d.month = d.day = 0
        return d

    # now we know the type of day-accurancy
    # nType = 0 means, that we dont found a day
    # nType = 1 means, we find day, when tithi was present at sunrise
    # nType = 2 means, we found day, when tithi started after sunrise
    #                  but ended before next sunrise
    #

    return d
コード例 #9
0
def CalcTithiEndEx(vcStart, GYear, nMasa, nPaksa, nTithi, earth, endTithi):
    d = GCGregorianDate()
    dtemp = GCGregorianDate()
    day = GCDayData()
    tithi = 0
    counter = 0
    sunrise = 0.0
    start = GCGregorianDate()
    end = GCGregorianDate()
    start.shour = -1.0
    end.shour = -1.0
    start.day = start.month = start.year = -1
    end.day = end.month = end.year = -1

    d.Set(vcStart)

    i = 0
    while True:
        d.AddDays(13)
        day.DayCalc(d, earth)
        day.nMasa = day.MasaCalc(d, earth)
        gy = day.nGaurabdaYear
        i += 1
        if ((day.nPaksa == nPaksa) and (day.nMasa == nMasa)) or i > 30:
            break

    if i > 30:
        d.year = d.month = d.day = -1
        return d

    # we found masa and paksa
    # now we have to find tithi
    tithi = nTithi + nPaksa * 15

    if day.nTithi == tithi:
        # loc1
        # find tithi juncts in this day and according to that times,
        # look in previous or next day for end and start of this tithi
        nType = 1
    else:
        if day.nTithi < tithi:
            # do increment of date until nTithi == tithi
            #   but if nTithi > tithi
            #       then do decrement of date
            counter = 0
            while counter < 30:
                d.NextDay()
                day.DayCalc(d, earth)
                if day.nTithi == tithi:
                    break
                if (day.nTithi < tithi) and (day.nPaksa != nPaksa):
                    d.PreviousDay()
                    break
                if day.nTithi > tithi:
                    d.PreviousDay()
                    break
                counter += 1
            # somewhere is error
            if counter >= 30:
                d.year = d.month = d.day = 0
                nType = 0
        else:
            # do decrement of date until nTithi <= tithi
            counter = 0
            while counter < 30:
                d.PreviousDay()
                day.DayCalc(d, earth)
                if day.nTithi == tithi:
                    break
                if (day.nTithi > tithi) and (day.nPaksa != nPaksa):
                    break
                if day.nTithi < tithi:
                    break
                counter += 1
            # somewhere is error
            if counter >= 30:
                d.year = d.month = d.day = 0
                nType = 0

        if day.nTithi == tithi:
            # do the same as in loc1
            nType = 1
        else:
            # nTithi != tithi and nTithi < tithi
            # but on next day is nTithi > tithi
            # that means we will find start and the end of tithi
            # in this very day or on next day before sunrise
            nType = 2

    # now we know the type of day-accurancy
    # nType = 0 means, that we dont found a day
    # nType = 1 means, we find day, when tithi was present at sunrise
    # nType = 2 means, we found day, when tithi started after sunrise
    #                  but ended before next sunrise
    #
    sunrise = day.sun.sunrise_deg / 360 + earth.tzone / 24

    if nType == 1:
        d1 = GCGregorianDate()
        d2 = GCGregorianDate()
        d.shour = sunrise
        GCTithi.GetPrevTithiStart(earth, d, d1)
        #d = d1
        #d.shour += 0.02
        GCTithi.GetNextTithiStart(earth, d, d2)

        endTithi.Set(d2)
        return d1
    elif nType == 2:
        d1 = GCGregorianDate()
        d2 = GCGregorianDate()
        d.shour = sunrise
        GCTithi.GetNextTithiStart(earth, d, d1)
        d.Set(d1)
        d.shour += 0.1
        d.NormalizeValues()
        GCTithi.GetNextTithiStart(earth, d, d2)

        endTithi.Set(d2)
        return d1

    # if nType == 0, then this algoritmus has some failure
    if nType == 0:
        d.year = 0
        d.month = 0
        d.day = 0
        d.shour = 0.0
        endTithi.Set(d)
    else:
        d.Set(start)
        endTithi.Set(end)

    return d
コード例 #10
0
def CalcTithiEnd(nGYear, nMasa, nPaksa, nTithi, earth, endTithi):
    d = GCGregorianDate(date=GetFirstDayOfYear(earth, nGYear + 1486))
    d.shour = 0.5
    d.tzone = earth.tzone

    return CalcTithiEndEx(d, nGYear, nMasa, nPaksa, nTithi, earth, endTithi)
コード例 #11
0
    def CalculateEvents(self, loc, vcStart, vcEnd):
        sun = SUNDATA()
        ndst = 0

        self.m_location.Set(loc)
        self.m_vcStart.Set(vcStart)
        self.m_vcEnd.Set(vcEnd)

        vcNext = GCGregorianDate()
        earth = loc.GetEarthData()

        vc = GCGregorianDate(date=vcStart)
        vcAdd = GCGregorianDate(date=vcStart)
        vcAdd.InitWeekDay()

        previousLongitude = -100
        todayLongitude = 0
        fromTimeLimit = 0

        while vcAdd.IsBeforeThis(vcEnd):
            if (GCDisplaySettings.getValue(COREEVENTS_SUN)):
                ndst = GCTimeZone.determineDaylightChange(
                    vcAdd, loc.m_nTimezoneId)
                sun.SunCalc(vcAdd, earth)

                vcAdd.shour = sun.arunodaya.GetDayTime()
                self.AddEvent(vcAdd, CCTYPE_S_ARUN, 0, ndst)

                vcAdd.shour = sunRise = sun.rise.GetDayTime()
                self.AddEvent(vcAdd, CCTYPE_S_RISE, 0, ndst)

                vcAdd.shour = sun.noon.GetDayTime()
                self.AddEvent(vcAdd, CCTYPE_S_NOON, 0, ndst)

                vcAdd.shour = sunSet = sun.set.GetDayTime()
                self.AddEvent(vcAdd, CCTYPE_S_SET, 0, ndst)
            else:
                ndst = GCTimeZone.determineDaylightChange(
                    vcAdd, loc.m_nTimezoneId)
                sun.SunCalc(vcAdd, earth)
                sunRise = sun.rise.GetDayTime()
                sunSet = sun.set.GetDayTime()

            if (GCDisplaySettings.getValue(COREEVENTS_ASCENDENT)):
                todayLongitude = sun.longitude_deg
                vcAdd.shour = sunRise
                todaySunriseHour = sunRise
                if (previousLongitude < -10):
                    prevSunrise = GCGregorianDate(date=vcAdd)
                    prevSunrise.PreviousDay()
                    sun.SunCalc(prevSunrise, earth)
                    previousSunriseHour = sun.rise.GetDayTime() - 1
                    previousLongitude = sun.longitude_deg
                    fromTimeLimit = 0

                jd = vcAdd.GetJulianComplete()
                ayan = GCAyanamsha.GetAyanamsa(jd)
                r1 = GCMath.putIn360(previousLongitude - ayan) / 30
                r2 = GCMath.putIn360(todayLongitude - ayan) / 30

                while (r2 > r1 + 13):
                    r2 -= 12.0
                while (r2 < r1 + 11):
                    r2 += 12.0

                a = (r2 - r1) / (todaySunriseHour - previousSunriseHour)
                b = r2 - a * todaySunriseHour

                tr = ceil(r1)
                for tr in range(ceil(r1), ceil(r2)):
                    tm = (tr - b) / a
                    if (tm > fromTimeLimit):
                        vcNext.Set(vcAdd)
                        vcNext.shour = tm
                        vcNext.NormalizeValues()
                        self.AddEvent(vcNext, CCTYPE_ASCENDENT, tr, ndst)

                previousLongitude = todayLongitude
                previousSunriseHour = todaySunriseHour - 1
                fromTimeLimit = previousSunriseHour

            if (GCDisplaySettings.getValue(COREEVENTS_RAHUKALAM)):
                r1, r2 = CalculateKala(sunRise, sunSet, vcAdd.dayOfWeek,
                                       KT_RAHU_KALAM)
                vcAdd.shour = r1
                self.AddEvent(vcAdd, CCTYPE_KALA_START, KT_RAHU_KALAM, ndst)
                vcAdd.shour = r2
                self.AddEvent(vcAdd, CCTYPE_KALA_END, KT_RAHU_KALAM, ndst)

            if (GCDisplaySettings.getValue(COREEVENTS_YAMAGHANTI)):
                r1, r2 = CalculateKala(sunRise, sunSet, vcAdd.dayOfWeek,
                                       KT_YAMA_GHANTI)
                vcAdd.shour = r1
                self.AddEvent(vcAdd, CCTYPE_KALA_START, KT_YAMA_GHANTI, ndst)
                vcAdd.shour = r2
                self.AddEvent(vcAdd, CCTYPE_KALA_END, KT_YAMA_GHANTI, ndst)

            if (GCDisplaySettings.getValue(COREEVENTS_GULIKALAM)):
                r1, r2 = CalculateKala(sunRise, sunSet, vcAdd.dayOfWeek,
                                       KT_GULI_KALAM)
                vcAdd.shour = r1
                self.AddEvent(vcAdd, CCTYPE_KALA_START, KT_GULI_KALAM, ndst)
                vcAdd.shour = r2
                self.AddEvent(vcAdd, CCTYPE_KALA_END, KT_GULI_KALAM, ndst)

            if (GCDisplaySettings.getValue(COREEVENTS_ABHIJIT_MUHURTA)):
                r1, r2 = CalculateKala(sunRise, sunSet, vcAdd.dayOfWeek,
                                       KT_ABHIJIT)
                if (r1 > 0 and r2 > 0):
                    vcAdd.shour = r1
                    self.AddEvent(vcAdd, CCTYPE_KALA_START, KT_ABHIJIT, ndst)
                    vcAdd.shour = r2
                    self.AddEvent(vcAdd, CCTYPE_KALA_END, KT_ABHIJIT, ndst)

            vcAdd.NextDay()

        if (GCDisplaySettings.getValue(COREEVENTS_TITHI)):
            vcAdd.Set(vc)
            vcAdd.shour = 0.0
            while vcAdd.IsBeforeThis(vcEnd):
                nData = GCTithi.GetNextTithiStart(earth, vcAdd, vcNext)
                if (vcNext.GetDayInteger() < vcEnd.GetDayInteger()):
                    vcNext.InitWeekDay()
                    ndst = GCTimeZone.determineDaylightChange(
                        vcNext, loc.m_nTimezoneId)
                    self.AddEvent(vcNext, CCTYPE_TITHI, nData, ndst)
                else:
                    break
                vcAdd.Set(vcNext)
                vcAdd.shour += 0.2
                if (vcAdd.shour >= 1.0):
                    vcAdd.shour -= 1.0
                    vcAdd.NextDay()

        if (GCDisplaySettings.getValue(COREEVENTS_NAKSATRA)):
            vcAdd.Set(vc)
            vcAdd.shour = 0.0
            while vcAdd.IsBeforeThis(vcEnd):
                nData = GCNaksatra.GetNextNaksatra(earth, vcAdd, vcNext)
                if (vcNext.GetDayInteger() < vcEnd.GetDayInteger()):
                    vcNext.InitWeekDay()
                    ndst = GCTimeZone.determineDaylightChange(
                        vcNext, loc.m_nTimezoneId)
                    self.AddEvent(vcNext, CCTYPE_NAKS, nData, ndst)
                else:
                    break
                vcAdd.Set(vcNext)
                vcAdd.shour += 0.2
                if (vcAdd.shour >= 1.0):
                    vcAdd.shour -= 1.0
                    vcAdd.NextDay()

        if (GCDisplaySettings.getValue(COREEVENTS_YOGA)):
            vcAdd.Set(vc)
            vcAdd.shour = 0.0
            while vcAdd.IsBeforeThis(vcEnd):
                nData = GCYoga.GetNextYogaStart(earth, vcAdd, vcNext)
                if (vcNext.GetDayInteger() < vcEnd.GetDayInteger()):
                    vcNext.InitWeekDay()
                    ndst = GCTimeZone.determineDaylightChange(
                        vcNext, loc.m_nTimezoneId)
                    self.AddEvent(vcNext, CCTYPE_YOGA, nData, ndst)
                else:
                    break
                vcAdd.Set(vcNext)
                vcAdd.shour += 0.2
                if (vcAdd.shour >= 1.0):
                    vcAdd.shour -= 1.0
                    vcAdd.NextDay()

        if (GCDisplaySettings.getValue(COREEVENTS_SANKRANTI)):
            vcAdd.Set(vc)
            vcAdd.shour = 0.0
            while vcAdd.IsBeforeThis(vcEnd):
                date, nData = GCSankranti.GetNextSankranti(vcAdd)
                vcNext.Set(date)
                if (vcNext.GetDayInteger() < vcEnd.GetDayInteger()):
                    vcNext.InitWeekDay()
                    ndst = GCTimeZone.determineDaylightChange(
                        vcNext, loc.m_nTimezoneId)
                    self.AddEvent(vcNext, CCTYPE_SANK, nData, ndst)
                else:
                    break
                vcAdd.Set(vcNext)
                vcAdd.NextDay()

        if (GCDisplaySettings.getValue(COREEVENTS_MOONRASI)):
            vcAdd.Set(vc)
            vcAdd.shour = 0.0
            while vcAdd.IsBeforeThis(vcEnd):
                nData = GetNextMoonRasi(earth, vcAdd, vcNext)
                if (vcNext.GetDayInteger() < vcEnd.GetDayInteger()):
                    vcNext.InitWeekDay()
                    ndst = GCTimeZone.determineDaylightChange(
                        vcNext, loc.m_nTimezoneId)
                    self.AddEvent(vcNext, CCTYPE_M_RASI, nData, ndst)
                else:
                    break
                vcAdd.Set(vcNext)
                vcAdd.shour += 0.5
                vcAdd.NormalizeValues()

        if (GCDisplaySettings.getValue(COREEVENTS_CONJUNCTION)):
            vcAdd.Set(vc)
            vcAdd.shour = 0.0
            while vcAdd.IsBeforeThis(vcEnd):
                dlong = GCConjunction.GetNextConjunctionEx(
                    vcAdd, vcNext, True, earth)
                if (vcNext.GetDayInteger() < vcEnd.GetDayInteger()):
                    vcNext.InitWeekDay()
                    ndst = GCTimeZone.determineDaylightChange(
                        vcNext, loc.m_nTimezoneId)
                    self.AddEvent(
                        vcNext, CCTYPE_CONJ,
                        GCRasi.GetRasi(
                            dlong,
                            GCAyanamsha.GetAyanamsa(
                                vcNext.GetJulianComplete())), ndst)
                else:
                    break
                vcAdd.Set(vcNext)
                vcAdd.NextDay()

        if (GCDisplaySettings.getValue(COREEVENTS_MOON)):
            vcAdd.Set(vc)
            vcAdd.shour = 0.0
            while vcAdd.IsBeforeThis(vcEnd):
                vcNext.Set(MOONDATA.GetNextRise(earth, vcAdd, True))
                self.AddEvent(vcNext, CCTYPE_M_RISE, 0, ndst)

                vcNext.Set(MOONDATA.GetNextRise(earth, vcNext, False))
                self.AddEvent(vcNext, CCTYPE_M_SET, 0, ndst)

                vcNext.shour += 0.05
                vcNext.NormalizeValues()
                vcAdd.Set(vcNext)

        if self.b_sorted:
            self.Sort()