def unittests():
    GCUT.info('result app')
    loc = GCLocation(
        data={
            'latitude': 48.150002,
            'longitude': 17.116667,
            'tzid': 321,
            'name': 'Bratislava, Slovakia'
        })
    earth = loc.GetEarthData()
    today = Today()

    tc = TAppDay()

    print('start calculate', datetime.datetime.now())
    tc.calculateAppDay(loc, today)
    print('end calculate', datetime.datetime.now())

    with open('test/app.xml', 'wt') as wf:
        tc.formatXml(wf)
    with open('test/app.txt', 'wt') as wf:
        tc.formatPlainText(wf)
    with open('test/app.rtf', 'wt') as wf:
        tc.formatRtf(wf)
    with open('test/app.html', 'wt') as wf:
        tc.writeHtml(wf)
Example #2
0
def unittests():
    GCUT.info('core events results')
    loc = GCLocation(
        data={
            'latitude': 48.150002,
            'longitude': 17.116667,
            'tzid': 321,
            'name': 'Bratislava, Slovakia'
        })
    earth = loc.GetEarthData()
    today = Today()
    future = GCGregorianDate(date=today, addDays=100)

    tc = TCoreEvents()

    print('start calculate', datetime.datetime.now())
    tc.CalculateEvents(loc, today, future)
    print('end calculate', datetime.datetime.now())

    with open('test/events.xml', 'wt') as wf:
        tc.formatXml(wf)
    with open('test/events.txt', 'wt') as wf:
        tc.formatText(wf)
    with open('test/events.rtf', 'wt') as wf:
        tc.formatRtf(wf)
    with open('test/events.html', 'wt') as wf:
        tc.writeHtml(wf)
def unittests():
    GCUT.info('daydata')
    e = GCEarthData.EARTHDATA()
    e.longitude_deg = 27.0
    e.latitude_deg = 45.0
    e.tzone = 1.0
    GCUT.msg('First day in year: ' + str(GetFirstDayOfYear(e, 2020)))
def unittests():
    GCUT.info('yoga')
    e = GCEarthData.EARTHDATA()
    e.longitude_deg = 27.0
    e.latitude_deg = 45.0
    e.tzone = 1.0
    vc = Today()
    vc2 = GCGregorianDate()
    GetNextYogaStart(e, vc, vc2)
    print('Next yoga:', repr(vc2))
def unittests():
    dt1 = GCTime(hour=1, min=23)
    dt2 = GCTime(hour=2, min=30)
    dt3 = GCTime(hour=5, min=10)

    GCUT.info('GCTime class')
    GCUT.val(dt1.ToLongTimeString(), '01:23:00', 'long time string')
    GCUT.val(dt3.IsGreaterThan(dt2), True, 'greater than')

    dt2.AddMinutes(176)
    GCUT.val(dt2.ToLongTimeString(), '05:26:00', 'add minutes')
    GCUT.val(dt3.IsLessThan(dt2), True, 'less than')
def unittests():
    GCUT.info('timezones')
    LoadFile('timezones.json')
    GCUT.msg('Timezones:' + str(len(gzone)))
    tz = GetTimeZone(id=321)
    vc = GCGregorianDate(year=2020, month=4, day=4)
    GCUT.val(GetDaylightBias(vc, tz), 1, 'daylight bias')
    GCUT.val(GetTimeZoneOffsetText(1.0), '+1:00', 'offset text')
Example #7
0
def unittests():
    GCUT.info('today results')
    loc = GCLocation(data={
        'latitude': 48.150002,
        'longitude': 17.116667,
        'tzid': 321,
        'name': 'Bratislava, Slovakia'
    })
    earth = loc.GetEarthData()
    today = Today()

    tc = TToday()

    print('start calculate', datetime.datetime.now())
    tc.Calculate(today,loc)
    print('end calculate', datetime.datetime.now())

    with open('test/today.txt','wt') as wf:
        tc.formatPlain(wf)
    with open('test/today.rtf','wt') as wf:
        tc.formatRtf(wf)
    with open('test/today.html','wt') as wf:
        tc.writeHtml(wf)
def unittests():
    GCUT.info('conjunctions')
    b = IsConjunction(10, 11, 12, 20)
    GCUT.val(b, True, 'is conjunction')

    e = GCEarthData.EARTHDATA()
    e.longitude_deg = 27.0
    e.latitude_deg = 45.0
    e.tzone = 1.0
    vc = Today()
    vc2 = GCGregorianDate(date=vc)
    vc3 = GCGregorianDate(date=vc)

    l = GetPrevConjunction(vc2, e)
    GCUT.msg('Conjunction on: {}'.format(repr(vc2)))
    vc2.Set(vc)
    l = GetNextConjunctionEx(vc2, vc3, True, e)
    GCUT.msg('Conjunction on: {}'.format(repr(vc3)))
Example #9
0
def unittests():
    GCUT.info('calendar')
    e = EARTHDATA()
    e.longitude_deg = 27.0
    e.latitude_deg = 45.0
    e.tzone = 1.0
    vc = Today()
    a = GetGaurabdaYear(vc, e)
    GCUT.msg('Gaurabda year:' + str(a))

    va = GCGaurabdaDate()
    Gregorian2Gaurabda(vc, va, e)
    GCUT.msg('Vatime: ' + str(va))

    va.prevMasa()
    va.tithi = 0
    vc2 = GCGregorianDate()
    Gaurabda2Gregorian(va, vc2, e)
    GCUT.msg('vctime2:' + str(vc2) + ' --> ' + str(va))
def unittests():
    GCUT.info('sundata')
    r1, r2 = CalculateKala(0.25, 0.75, 0, KalaType.KT_ABHIJIT)
    GCUT.msg('abhijit on sunday {} {}'.format(r1, r2))
    s = SUNDATA()
    e = GCEarthData.EARTHDATA()
    e.longitude_deg = 27.0
    e.latitude_deg = 45.0
    e.tzone = 1.0
    vc = GCGregorianDate.Today()
    s.SunCalc(vc, e)
    GCUT.msg(str(repr(s)))
def unittests():
    GCUT.info('sankranti')
    vc = Today()
    vc2 = GCGregorianDate()
    vc3 = GCGregorianDate(date=vc)
    vc3.AddDays(100)
    n = GetSankMethodName(GetSankrantiType())
    GCUT.msg('Sankranti Type: {}'.format(n))
    import io
    s = io.StringIO()
    clr = GCLocation()
    writeXml(s, clr, vc, vc3)
    GCUT.msg(s.getvalue())
def unittests():
    GCUT.info('string builder')
    s = io.StringIO()
    sb = GCStringBuilder(s)
    GCUT.msg('testing TEXT')
    sb.AppendString('aaa')
    sb.AppendDocumentHeader()
    sb.AppendDocumentTail()
    sb.AppendNote()
    sb.AppendSeparatorWithWidth(30)
    GCUT.msg('testing RTF')
    sb.AppendString('aaa')
    sb.AppendBoldString('aaa')
    sb.AppendDocumentHeader()
    sb.AppendDocumentTail()
    sb.AppendNote()
    sb.AppendSeparatorWithWidth(30)
Example #13
0
import gaurabda.GCYoga as GCYoga
import gaurabda.GCLocationList as GCLocationList
import gaurabda.GCEventList as GCEventList
import gaurabda.GCCalendar as GCCalendar
import TMasaList
import TCalendar
import TAppDay
import TCoreEvents
import TToday
import os

os.mkdir('test')

GCMath.unittests()
GCTime.unittests()
GCUT.info('enums')
GCUT.val(FastType.FAST_NULL, 0, 'FastType')
GCUT.val(MahadvadasiType.EV_VIJAYA, 0x110, 'MahadvadasiType')
GCAyanamsha.unittests()
GCPancangaDate.unittests()
GCDisplaySettings.unittests()
GCStrings.unittests()
GCCountry.unittests()
GCGregorianDate.unittests()
GCTimeZone.unittests()
GCEarthData.unittests()
GCStringBuilder.unittests()
GCMoonData.unittests()
GCSunData.unittests()
GCConjunction.unittests()
GCNaksatra.unittests()
Example #14
0
def unittests():
    GCUT.info('display settings')
    GCUT.val(getValue(6),1,'get Value')
Example #15
0
def unittests():
    GCUT.info('ayanamsha')
    GCUT.nval(len(GetAyanamsaName(ayamashaType)), 0, 'ayanamsa name')
    GCUT.nval(GetAyanamsa(2000000), 0.0, 'ayanamsha value')
Example #16
0
def unittests():
    GCUT.info('GCGregorianDate')
    t = GCGregorianDate()
    GCUT.val(t.day, 0, 'zero day')
    t.Today()
    GCUT.nval(t.day, 0, 'init day')
    GCUT.nval(t.month, 0, 'init month')
    GCUT.msg('Today: ' + str(t))
    GCUT.msg('Now: ' + repr(t))
def unittests():
    GCUT.info('location list')
    OpenFile('locations.json')
    GCUT.nval(LocationCount(), 0, 'location count')
    lc = LocationAtIndex(0)
    print(lc.data())
def unittests():
    GCUT.info('moon data')
    ed = GCEarthData.EARTHDATA()
    ed.longitude_deg = 20.0
    ed.latitude_deg = 45.0
    ed.tzone = 1.0
    vc = GCGregorianDate.GCGregorianDate(2000, 1, 1, 0.5)
    GCUT.msg('Moon distance: ' + str(MoonDistance(vc.GetJulianComplete())))
    nd = GetNextRise(ed, vc, True)
    GCUT.msg('Next rise: ' + repr(nd))
    nd = GetNextRise(ed, vc, False)
    GCUT.msg('Next set: ' + repr(nd))
    a, b = GetNextMoonRasi(ed, vc)
    GCUT.msg('next moon rasi: {} {}'.format(a, b))
    a, b = CalcMoonTimes(ed, vc, 1.0)
    GCUT.msg('moon times: {} {}'.format(repr(a), repr(b)))
Example #19
0
def unittests():
    GCUT.info('gc tithi')
    e = GCEarthData.EARTHDATA()
    e.longitude_deg = 27.0
    e.latitude_deg = 45.0
    e.tzone = 1.0
    vc = Today()
    vc2 = GCGregorianDate()
    vc3 = GCGregorianDate(date=vc)
    vc3.NextDay()

    if False:
        import io
        s = io.StringIO()
        clr = GCLocation.GCLocation()
        writeXml(s, clr, vc)
        GCUT.msg(s.getvalue())
        s.seek(0)
        writeGaurabdaTithiXml(s, clr, GCGaurabdaDate(2, 1, 512),
                              GCGaurabdaDate(20, 1, 514))
        GCUT.msg('writeGaurabdaTithiXml')
        GCUT.msg(s.getvalue())

        s = io.StringIO()
        writeGaurabdaNextTithiXml(s, clr, vc, GCGaurabdaDate(2, 1, 512))
        GCUT.msg('writeGaurabdaNextTithiXml')
        GCUT.msg(s.getvalue())

    print(GetTithiTimes(e, vc, 0.25))
Example #20
0
def unittests():
    GCUT.info('gc math')
    GCUT.val(Max(1, 2), 2, 'max')
    GCUT.val(sinDeg(90), 1.0, 'sin')
    GCUT.val(cosDeg(0), 1.0, 'cos')
    GCUT.val(putIn24(30), 6, 'putIn24')
    GCUT.val(Floor(1.3), 1.0, 'Floor')
    GCUT.val(Floor(-1.3), -2.0, 'Floor')
def unittests():
    GCUT.info('strings')
    readFile('strings.json')
    GCUT.nval(len(gstr), 0, 'read strings')
    GCUT.val(GetDayOfWeek(0), 'Sunday', 'day of week')
    GCUT.val(GetMasaName(0), 'Madhusudana', 'masa name')
Example #22
0
def unittests():
    GCUT.info('earth data')
    GCUT.val(GetTextLatitude(12.5), '12N30', 'text latitude')
    GCUT.val(GetTextLongitude(-15.25), '15W15', 'text longitude')
    GCUT.val(star_time(2451545.0), 280.45704234942144, 'start time')
    dp, ep = calc_epsilon_phi(2451545.0)
    GCUT.val(dp, -0.0038975991170544155, 'delta phi')
    GCUT.val(ep, 23.437690731210242, 'epsilon')
Example #23
0
def unittests():
    GCUT.info('custom events')
    a = OpenFile('events.json')
    GCUT.nval(a,0,'open file')
    print(list[0].data)
Example #24
0
def unittests():
    GCUT.info('countries')
    GCUT.nval(InitWithFile('countries.json'), 0, 'load countries')
    GCUT.msg('count:' + str(len(gcountries)))
    country = FindCountry(name='India')
    GCUT.val(country['abbr'], 'IN', 'find country')
Example #25
0
def unittests():
    GCUT.info('GCGaurabdaDate')
    va = GCGaurabdaDate()
    GCUT.val(va.tithi, 0, 'day')
    va.next()
    GCUT.val(va.tithi, 1, 'next')
    va.prev()
    va.prev()
    GCUT.val(va.tithi, 29, 'prev-tithi')
    GCUT.val(va.masa, 11, 'prev-masa')
    GCUT.val(va.gyear, 519, 'prev-gyear')