def writeFirstDayXml(xml, loc, vc): vcStart = GCGregorianDate( date=GetFirstDayOfYear(loc.GetEarthData(), vcStart.year)) vcStart.InitWeekDay() # write xml.write("<xml>\n") xml.write("\t<request name=\"FirstDay\" 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=\"year\" val=\"") xml.write(str(vcStart.year)) xml.write("\" />\n") xml.write("\t</request>\n") xml.write("\t<result name=\"FirstDay_of_GaurabdaYear\">\n") xml.write("\t\t<firstday date=\"") xml.write(str(vcStart)) xml.write("\" dayweekid = \"") xml.write(str(vcStart.dayOfWeek)) xml.write("\" dayweek=\"") xml.write(GCStrings.getString(vcStart.dayOfWeek)) xml.write("\" />\n") xml.write("\t</result>\n") xml.write("</xml>\n") return 0
def formatRtf(self, stream): sb = GCStringBuilder.GCStringBuilder(stream) sb.Format = GCStringBuilder.SBTF_RTF sb.fontSizeH1 = GCLayoutData.textSizeH1 sb.fontSizeH2 = GCLayoutData.textSizeH2 sb.fontSizeText = GCLayoutData.textSizeText sb.fontSizeNote = GCLayoutData.textSizeNote sb.AppendDocumentHeader() stream.write( "{{\\fs{}\\f2 {} }}\\par\\tx{}\\tx{}\\f2\\fs{}\r\n\\par\r\n{}: {}\\par\r\n" .format(GCLayoutData.textSizeH1, GCStrings.getString(39), 1000 * GCLayoutData.textSizeText / 24, 4000 * GCLayoutData.textSizeText / 24, GCLayoutData.textSizeText, GCStrings.getString(40), self.location.m_strFullName)) stream.write("{} {} {} {}\\par\r\n".format(GCStrings.getString(41), str(self.start), GCStrings.getString(42), str(self.end))) sb.AppendSeparatorWithWidth(65) sb.AppendLine() sb.AppendLine() for m in self.arr: stream.write('\\tab {} {}\\tab '.format(m['masaName'], m['year'])) stream.write('{} - '.format(str(m['start']))) stream.write('{}\\par\r\n'.format(str(m['end']))) sb.AppendNote() sb.AppendDocumentTail() return 1
def GetFullTithiName(self): str = GCStrings.GetTithiName(self.astrodata.nTithi) if (self.astrodata.nTithi == 10) or (self.astrodata.nTithi == 25) or ( self.astrodata.nTithi == 11) or (self.astrodata.nTithi == 26): if self.ekadasi_parana == False: str += " " if self.nMhdType == MahadvadasiType.EV_NULL: str += GCStrings.getString(58) else: str += GCStrings.getString(59) return str
def GetDateTextWithTodayExt(self): if (self.day > 0) and (self.day < 32) and (self.month > 0) \ and (self.month < 13) and (self.year >= 1500) and (self.year < 4000): today = GCGregorianDate() diff = today.GetJulianInteger() - self.GetJulianInteger() if diff == 0: return str(self) + ' ' + GCStrings.getString(43) elif diff == -1: return str(self) + ' ' + GCStrings.getString(854) elif diff == 1: return str(self) + ' ' + GCStrings.getString(853) else: return str(self)
def writeHtml(self, stream): stream.write("<html>\n<head>\n<title>Core Events</title>\n\n") stream.write( "<style>\n<!--\nbody {\n font-family:Verdana;\n font-size:11pt;\n}\n\ntd.hed {\n font-size:11pt;\n font-weight:bold;\n" ) stream.write( " background:#aaaaaa;\n color:white;\n text-align:center;\n vertical-align:center;\n padding-left:15pt;\n padding-right:15pt;\n" ) stream.write( " padding-top:5pt;\n padding-bottom:5pt;\n}\n-->\n</style>\n") stream.write("</head>\n") stream.write("<body>\n\n") stream.write( "<h1 align=center>Events</h1>\n<p align=center>From {} to {}.</p>\n\n" .format(self.m_vcStart, self.m_vcEnd)) stream.write("<p align=center>{}</p>\n".format( self.m_location.m_strFullName)) prevd = GCGregorianDate() prevd.day = 0 prevd.month = 0 prevd.year = 0 prevt = -1 stream.write("<table align=center><tr>\n") last_header = '' new_header = '' for dnr in self.p_events: if self.b_sorted: new_header = " {} - {} ".format( dnr.Time, GCStrings.GetDayOfWeek(dnr.Time.dayOfWeek)) else: new_header = self.header_text[dnr.nType] if last_header != new_header: stream.write( f"<td class=\"hed\" colspan=2>{new_header}</td></tr>\n<tr>\n" ) last_header = new_header stream.write("<td>{}</td><td>{}</td></tr><tr>\n".format( dnr.EventText(), dnr.Time.time_str())) stream.write("</tr></table>\n") stream.write( "<hr align=center width=\"50%%\">\n<p align=center>Generated by {}</p>" .format(GCStrings.getString(130))) stream.write("</body>\n</html>\n") return 1
def formatRtf(self, stream): sb = GCStringBuilder(stream) sb.Format = SBTF_RTF sb.fontSizeH1 = GCLayoutData.textSizeH1 sb.fontSizeH2 = GCLayoutData.textSizeH2 sb.fontSizeText = GCLayoutData.textSizeText sb.fontSizeNote = GCLayoutData.textSizeNote sb.AppendDocumentHeader() sb.AppendHeader1("Events") stream.write("\\par from {} to {}.\\par\r\n\\par\r\n".format( self.m_vcStart, self.m_vcEnd)) stream.write("{}\\par\r\n\\par\r\n".format( self.m_location.m_strFullName)) prevd = GCGregorianDate() prevd.day = 0 prevd.month = 0 prevd.year = 0 prevt = -1 last_header = '' for dnr in self.p_events: new_header = '' if self.b_sorted: new_header = " {} - {} ".format( dnr.Time, GCStrings.GetDayOfWeek(dnr.Time.dayOfWeek)) else: new_header = header_text[dnr.nType] if last_header != new_header: sb.AppendLine() sb.AppendHeader2(new_header) sb.AppendLine() last_header = new_header stream.write("\\par {} {} {}".format( dnr.Time.time_str(), GCStrings.GetDSTSignature(dnr.nDst), dnr.EventText())) sb.AppendLine() sb.AppendNote() sb.AppendDocumentTail() return 1
def writeHtml(self, stream): stream.write("<html>\n<head>\n<title>Masa List</title>\n\n") stream.write( "<style>\n<!--\nbody {\n font-family:Verdana;\n font-size:11pt;\n}\n\ntd.hed {\n font-size:11pt;\n font-weight:bold;\n" ) stream.write( " background:#aaaaaa;\n color:white;\n text-align:center;\n vertical-align:center;\n padding-left:15pt;\n padding-right:15pt;\n" ) stream.write( " padding-top:5pt;\n padding-bottom:5pt;\n}\n-->\n</style>\n") stream.write("</head>\n") stream.write("<body>\n\n") stream.write( "<p style=\'text-align:center\'><span style=\'font-size:14pt\'>Masa List</span></br>{}: {}</p>\n" .format(GCStrings.getString(40), self.location.m_strFullName)) stream.write("<p align=center>{} {} {} {} </p>\n".format( GCStrings.getString(41), str(self.start), GCStrings.getString(42), str(self.end))) stream.write("<hr width=\"50%\">") stream.write("<table align=center>") stream.write( "<tr><td class=\"hed\" style=\'text-align:left\'>MASA NAME </td><td class=\"hed\">START</td><td class=\"hed\">END</td></tr>" ) for m in self.arr: stream.write("<tr>") stream.write("<td>{} {} </td>".format( m['masaName'], m['year'])) stream.write("<td>{}</td>".format(str(m['start']))) stream.write("<td>{}</td>".format(str(m['end']))) stream.write("</tr>") stream.write("</table>") stream.write( "<hr width=\"50%%\">\n<p align=center>Generated by {}</p>".format( GCStrings.getString(130))) stream.write("</body></html>") return 1
def GetTextRtf(self): str = "\\par {} {}\\tab {}\\tab ".format( self.date, GCStrings.GetDayOfWeek(self.date.dayOfWeek)[:2], self.GetFullTithiName()) if GCDisplaySettings.getValue(39): str += GCStrings.GetPaksaChar(self.astrodata.nPaksa) + ' ' else: str += ' ' if GCDisplaySettings.getValue(37): str += '\\tab {}'.format( GCStrings.GetYogaName(self.astrodata.nYoga)) if GCDisplaySettings.getValue(36): str += '\\tab {}'.format( GCStrings.GetNaksatraName(self.astrodata.nNaksatra)) if GCDisplaySettings.getValue( 38) and self.nFastType != FastType.FAST_NULL: str += "\\tab *" else: str += "\\tab " if GCDisplaySettings.getValue(41): rasi = GCRasi.GetRasi(self.astrodata.moon.longitude_deg, self.astrodata.msAyanamsa) if GCDisplaySettings.getValue(41) == 1: str += "\\tab {}".format(GCStrings.GetSankrantiName(rasi)) else: str += "\\tab {}".format(GCStrings.GetSankrantiNameEn(rasi)) str += "\r\n" return str
def formatText(self, stream): sb = GCStringBuilder(stream) sb.Format = SBTF_TEXT stream.write("Events from {} to {}.\r\n\r\n".format( self.m_vcStart, self.m_vcEnd)) stream.write("{}\r\n\r\n".format(self.m_location.m_strFullName)) prevd = GCGregorianDate() prevd.day = 0 prevd.month = 0 prevd.year = 0 prevt = -1 last_header = '' for dnr in self.p_events: new_header = '' if self.b_sorted: new_header = " {} - {} ".format( dnr.Time, GCStrings.GetDayOfWeek(dnr.Time.dayOfWeek)) else: new_header = header_text[dnr.nType] if last_header != new_header: sb.AppendLine() sb.AppendHeader3(new_header) sb.AppendLine() last_header = new_header stream.write(" {} {} {}".format( dnr.Time.time_str(), GCStrings.GetDSTSignature(dnr.nDst), dnr.EventText())) sb.AppendLine() sb.AppendLine() sb.AppendNote() return 1
def formatText(self, stream): sb = GCStringBuilder.GCStringBuilder(stream) sb.Format = GCStringBuilder.SBTF_TEXT stream.write(" {}\r\n\r\n{}: {}\r\n".format( GCStrings.getString(39), GCStrings.getString(40), self.location.m_strFullName)) stream.write("{} {} {} {}\r\n".format(GCStrings.getString(41), str(self.start), GCStrings.getString(42), str(self.end))) stream.write("=" * 65) stream.write("\r\n\r\n") for m in self.arr: stream.write('{:30s}'.format('{} {}'.format( m['masaName'], m['year']))) stream.write(' {} - {}\r\n'.format( str(m['start']).rjust(12, ' '), str(m['end']).rjust(12, ' '))) sb.AppendNote() sb.AppendDocumentTail() return 1
def formatXml(self, strXml): strXml.write( "<xml>\r\n<program version=\"{}\">\r\n<location longitude=\"{}\" latitude=\"{}\" timezone=\"{}\" dst=\"{}\" />\n" .format(GCStrings.getString(130), self.m_location.m_fLongitude, self.m_location.m_fLatitude, self.m_location.m_fTimezone, GCTimeZone.GetTimeZoneName(self.m_location.m_nTimezoneId))) for dnr in self.p_events: strXml.write( " <event type=\"{}\" date=\"{}\" time=\"{}\" dst=\"{}\" />\n". format(dnr.EventText(), str(dnr.Time), dnr.Time.time_str(), dnr.nDst)) strXml.write("</xml>\n") return 1
def writeXml(self, stream): stream.write("<xml>\r\n") stream.write(" <body title=\"Masa List\">\n\n") stream.write(" <location>{}</location>\r\n".format( self.location.m_strFullName)) stream.write(" <masalist>\r\n") for m in self.arr: stream.write( " <masa name=\"{}\" year=\"{}\" start=\"{}\" end=\"{}\" />\r\n" .format(m['masaName'], m['year'], str(m['start']), str(m['end']))) stream.write(" </masalist>\r\n") stream.write(" <author>{}</author>\r\n".format( GCStrings.getString(130))) stream.write(" </body>\r\n</xml>\r\n") return 1
def EventText(self): if self.nType == CCTYPE_S_ARUN: return 'arunodaya' elif self.nType == CCTYPE_S_RISE: return "sunrise" elif self.nType == CCTYPE_S_NOON: return "noon" elif self.nType == CCTYPE_S_SET: return "sunset" elif self.nType == CCTYPE_TITHI: return GCStrings.GetTithiName(self.nData) + " Tithi starts" elif self.nType == CCTYPE_NAKS: return GCStrings.GetNaksatraName(self.nData) + " Naksatra starts" elif self.nType == CCTYPE_YOGA: return GCStrings.GetYogaName(self.nData) + " Yoga starts" elif self.nType == CCTYPE_SANK: return "Sun enters {}".format( GCStrings.GetSankrantiName(self.nData)) elif self.nType == CCTYPE_CONJ: return "conjunction in {} rasi".format( GCStrings.GetSankrantiName(self.nData)) elif self.nType == CCTYPE_KALA_START: return GCStrings.GetKalaName(self.nData) + " starts" elif self.nType == CCTYPE_KALA_END: return GCStrings.GetKalaName(self.nData) + " ends" elif self.nType == CCTYPE_M_RISE: return "moonrise" elif self.nType == CCTYPE_M_SET: return "moonset" elif self.nType == CCTYPE_ASCENDENT: return GCStrings.GetSankrantiName(self.nData) + " ascendent" elif self.nType == CCTYPE_M_RASI: return "Moon enters {}".format( GCStrings.GetSankrantiName(self.nData)) else: return ''
def CalculateMasaList(self, loc, year, count): day = GCDayData() earth = loc.GetEarthData() self.startYear = year self.countYears = count self.start = GCGregorianDate(date=GetFirstDayOfYear(earth, year)) self.end = GCGregorianDate(date=GetFirstDayOfYear(earth, year + count)) self.location = GCLocation() self.location.Set(loc) i = 0 prev_masa = -1 prev_paksa = -1 prev_gyear = -1 current = 0 d = GCGregorianDate(date=self.start) while d.IsBeforeThis(self.end): day.DayCalc(d, earth) if prev_paksa != day.nPaksa: day.nMasa = day.MasaCalc(d, earth) if prev_masa != day.nMasa: if len(self.arr) > 0: self.arr[-1]['end'] = GCGregorianDate(date=d, addDays=-1) prev_masa = day.nMasa self.arr.append({ 'masa': day.nMasa, 'masaName': GCStrings.GetMasaName(day.nMasa), 'year': day.nGaurabdaYear, 'start': GCGregorianDate(date=d) }) prev_paksa = day.nPaksa d.NextDay() self.arr[-1]['end'] = GCGregorianDate(date=d, addDays=-1) return len(self.arr)
def AppendNote(self): self.AppendLine() self.AppendLine() self.AppendSeparatorWithWidth(80) self.AppendLine() self.AppendBoldString("Notes:") self.AppendLine() self.AppendLine() self.AppendLine("DST - Time is in \'Daylight Saving Time\'") self.AppendLine("LT - Time is in \'Local Time\'\r\n") if GCDisplaySettings.getValue(9) > 0 or GCDisplaySettings.getValue( 10) > 0 or GCDisplaySettings.getValue( 11) > 0 or GCDisplaySettings.getValue(12) > 0: self.AppendLine("(*) - value at the moment of sunrise") # last line self.AppendLine() self.AppendString("Generated by ") self.AppendString(GCStrings.getString(132))
def formatXml(self, stream): d = self.details vc = GCGregorianDate(date=self.eventTime) m_earth = self.m_location.GetEarthData() loc = self.m_location bDuringAdhika = False stream.write('''<xml> <request name="AppDay" version="{}"> <arg name="longitude" value="{}" /> <arg name="latitude" value="{}" /> <arg name="timezone" value="{}" /> <arg name="year" value="{}" /> <arg name="month" value="{}" /> <arg name="day" value="{}" /> <arg name="hour" value="{}" /> <arg name="minute" value="{}" /> </request>'''.format(GCStrings.getString(130), loc.m_fLongitude, loc.m_fLatitude, loc.m_fTimezone, self.eventTime.year, self.eventTime.month, self.eventTime.day, self.eventTime.GetHour(), self.eventTime.GetMinuteRound())) npada = int(floor(d.nNaksatraElapse / 25.0)) + 1 if (npada > 4): npada = 4 is_adhika = "yes" if bDuringAdhika else "no" stream.write( "\t<result name=\"AppDay\" >\n\t\t<tithi name=\"{}\" elapse=\"%f\" />\n\t\t<naksatra name=\"{}\" elapse=\"%f\" pada=\"{}\"/>\n\t\t<paksa name=\"{}\" />\n\t\t<masa name=\"{}\" adhikamasa=\"{}\"/>\n\t\t<gaurabda value=\"{}\" />\n" .format(GCStrings.GetTithiName(d.nTithi), d.nTithiElapse, GCStrings.GetNaksatraName(d.nNaksatra), d.nNaksatraElapse, npada, GCStrings.GetPaksaName(d.nPaksa), GCStrings.GetMasaName(d.nMasa), is_adhika, d.nGaurabdaYear)) stream.write("\t\t<celebrations>\n") for i in range(TRESULT_APP_CELEBS): stream.write( "\t\t\t<celebration gaurabda=\"{}\" day=\"{}\" month=\"{}\" monthabr=\"{}\" year=\"{}\" />\n" .format( self.celeb_gy[i], self.celeb_date[i].day, self.celeb_date[i].month, GCStrings.GetMonthAbreviation(self.celeb_date[i].month), self.celeb_date[i].year)) stream.write("\t\t</celebrations>\n\t</result>\n</xml>\n")
def writeHtml(self, stream): p = self.GetCurrentDay() loc = self.calendar.m_Location vc = p.date sb = GCStringBuilder(stream) sb.Format = SBTF_HTML if (p == None): return stream.write("<html>\n<head>\n<title></title>") stream.write("<style>\n<!--\nbody {\n font-family:Verdana;\n font-size:9.5pt;\n}\n\ntd.hed {\n font-size:9.5pt;\n font-weight:bold;\n") stream.write(" background:#aaaaaa;\n color:white;\n text-align:center;\n vertical-align:center;\n padding-left:15pt;\n padding-right:15pt;\n") stream.write(" padding-top:5pt;\n padding-bottom:5pt;\n}\n-->\n</style>\n") stream.write("</head>\n") stream.write("<body>\n") stream.write("<h2>{}</h2>\n".format(vc.GetDateTextWithTodayExt())) stream.write("<h4>{}</h4>\n".format(loc.m_strFullName)) stream.write("<p> {}, {} {}<br> {} {}, {} Gaurabda</p>".format(GCStrings.GetTithiName(p.astrodata.nTithi), GCStrings.GetPaksaName(p.astrodata.nPaksa), GCStrings.getString(20), GCStrings.GetMasaName(p.astrodata.nMasa), GCStrings.getString(22), p.astrodata.nGaurabdaYear)) prevCountFest = 0 stream.write("<p>") self.WriteTodayInfo(sb,p)
def GetTextA(self): str = "{} {} {} ".format( self.date.__str__().rjust(12, ' '), GCStrings.GetDayOfWeek(self.date.dayOfWeek)[:2], self.GetFullTithiName().ljust(34, ' ')) if GCDisplaySettings.getValue(39): str += GCStrings.GetPaksaChar(self.astrodata.nPaksa) + ' ' else: str += ' ' if GCDisplaySettings.getValue(37): str += '{}'.format( GCStrings.GetYogaName(self.astrodata.nYoga).ljust(10, ' ')) if GCDisplaySettings.getValue(36): str += '{}'.format( GCStrings.GetNaksatraName(self.astrodata.nNaksatra).ljust( 15, ' ')) if GCDisplaySettings.getValue( 38) and self.nFastType != FastType.FAST_NULL: str += " *" else: str += " " if GCDisplaySettings.getValue(41): rasi = GCRasi.GetRasi(self.astrodata.moon.longitude_deg, self.astrodata.msAyanamsa) if GCDisplaySettings.getValue(41) == 1: str += " {}".format( GCStrings.GetSankrantiName(rasi).ljust(15, ' ')) else: str += " {}".format( GCStrings.GetSankrantiNameEn(rasi).ljust(15, ' ')) return str
def __str__(self): return '{}: {} {}: {} {}: {}'.format( GCStrings.getString(10), GetTextLatitude(latitude_deg), GCStrings.getString(11), GetTextLongitude(longitude_deg), GCStrings.getString(12), GCTimeZone.GetTimeZoneOffsetText(tzone))
def __str__(self): return '{} {} {:04d}'.format(self.day, GCStrings.GetMonthAbreviation(self.month), self.year)
def AddSpecFestival(self, nSpecialFestival, nFestClass): str = '' fasting = -1 fastingSubject = None if nSpecialFestival == SpecialFestivalId.SPEC_JANMASTAMI: str = GCStrings.getString(741) fasting = 5 fastingSubject = "Sri Krsna" elif nSpecialFestival == SpecialFestivalId.SPEC_GAURAPURNIMA: str = GCStrings.getString(742) fasting = 3 fastingSubject = "Sri Caitanya Mahaprabhu" elif nSpecialFestival == SpecialFestivalId.SPEC_RETURNRATHA: str = GCStrings.getString(743) elif nSpecialFestival == SpecialFestivalId.SPEC_HERAPANCAMI: str = GCStrings.getString(744) elif nSpecialFestival == SpecialFestivalId.SPEC_GUNDICAMARJANA: str = GCStrings.getString(745) elif nSpecialFestival == SpecialFestivalId.SPEC_GOVARDHANPUJA: str = GCStrings.getString(746) elif nSpecialFestival == SpecialFestivalId.SPEC_RAMANAVAMI: str = GCStrings.getString(747) fasting = 2 fastingSubject = "Sri Ramacandra" elif nSpecialFestival == SpecialFestivalId.SPEC_RATHAYATRA: str = GCStrings.getString(748) elif nSpecialFestival == SpecialFestivalId.SPEC_NANDAUTSAVA: str = GCStrings.getString(749) elif nSpecialFestival == SpecialFestivalId.SPEC_PRABHAPP: str = GCStrings.getString(759) fasting = 1 fastingSubject = "Srila Prabhupada" elif nSpecialFestival == SpecialFestivalId.SPEC_MISRAFESTIVAL: str = GCStrings.getString(750) else: return False md = self.AddEvent(PRIO_FESTIVALS_0 + (nFestClass - CAL_FEST_0) * 100, nFestClass, str) if fasting > 0: md['fasttype'] = fasting md["fastsubject"] = fastingSubject return False
def MonthAbrToInt(self, text): if len(text) > 3: text = text[:3] for i in range(65, 78): if GCStrings.getString(i).lower() == text.lower(): return i - 64 raise
def __repr__(self): return "{:2d} {} {:04d} {:02d}:{:02d}:{:02d}".format( self.day, GCStrings.GetMonthAbreviation(self.month), self.year, self.GetHour(), self.GetMinute(), self.GetSecond())
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
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
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
def writeXml(xml, loc, vcStart, vcEnd): dt = GCTime() zodiac = 0 d = GCGregorianDate(date=vcStart) xml.write("<xml>\n") xml.write("\t<request name=\"Sankranti\" 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=\"location\" val=\"") xml.write(loc.m_strName) xml.write("\" />\n") xml.write("\t\t<arg name=\"startdate\" val=\"") xml.write(repr(vcStart)) xml.write("\" />\n") xml.write("\t\t<arg name=\"enddate\" val=\"") xml.write(repr(vcEnd)) xml.write("\" />\n") xml.write("\t</request>\n") xml.write("\t<result name=\"SankrantiList\">\n") while d.IsBeforeThis(vcEnd): nextDate, zodiac = GetNextSankranti(d) d.Set(nextDate) d.InitWeekDay() xml.write("\t\t<sank date=\"") xml.write(str(d)) xml.write("\" ") xml.write("dayweekid=\"") xml.write(str(d.dayOfWeek)) xml.write("\" dayweek=\"") xml.write(GCStrings.getString(d.dayOfWeek)) xml.write("\" ") dt.SetDegTime(360 * d.shour) xml.write(" time=\"") xml.write(repr(dt)) xml.write("\" >\n") xml.write("\t\t\t<zodiac sans=\"") xml.write(GCStrings.GetSankrantiName(zodiac)) xml.write("\" eng=\"") xml.write(GCStrings.GetSankrantiNameEn(zodiac)) xml.write("\" id=\"") xml.write(str(zodiac)) xml.write("\" />\n") xml.write("\t\t</sank>\n") d.NextDay() d.NextDay() xml.write("\t</result>\n") xml.write("</xml>") return 1
import gaurabda.GCStrings as GCStrings import gaurabda.GCCountry as GCCountry import gaurabda.GCLocation as GCLocation import gaurabda.GCLocationList as GCLocationList import gaurabda.GCDisplaySettings as GCDisplaySettings import gaurabda.GCEventList as GCEventList import gaurabda.GCTimeZone as GCTimeZone GCStrings.readFile('strings.json') GCCountry.InitWithFile('countries.json') GCTimeZone.LoadFile('timezones.json') GCLocationList.OpenFile('locations.json') GCDisplaySettings.readFile('displays.json') myLocation = GCLocation.GCLocation(data={ 'latitude': 27.583, 'longitude': 77.73, 'tzid': 188, 'name': 'Vrndavan, India' }) lastLocation = GCLocation.GCLocation(data={ 'latitude': 27.583, 'longitude': 77.73, 'tzid': 188, 'name': 'Vrndavan, India' }) GCEventList.SetOldStyleFasting(GCDisplaySettings.getValue(42))
def FormatDate(vc, va): return "{} {} {}\r\n{}, {} Paksa, {} Masa, {}".format( vc.day, GCStrings.GetMonthAbreviation(vc.month), vc.year, GCStrings.GetTithiName(va.tithi % 15), GCStrings.GetPaksaName(va.paksa), GCStrings.GetMasaName(va.masa), va.gyear)
def __str__(self): return '{} {}, {} Masa, {}'.format(GCStrings.GetTithiName(self.tithi), GCStrings.GetPaksaName(self.paksa), GCStrings.GetMasaName(self.masa), self.gyear)