Example #1
0
 def test_to_jd(self):
     for date, jd in self.dateToJdDict.items():
         jdActual = gregorian.to_jd(*date)
         self.assertEqual(
             jdActual,
             jd,
             f"date={date}, jd={jd}, jdActual={jdActual}",
         )
Example #2
0
 def test_convert(self):
     startYear = 1950
     endYear = 2050
     for year in range(startYear, endYear):
         for month in range(1, 13):
             monthLen = getMonthLen(year, month)
             for day in range(1, monthLen + 1):
                 date = (year, month, day)
                 jd = gregorian.to_jd(*date)
                 ndate = gregorian.jd_to(jd)
                 self.assertEqual(
                     ndate,
                     date,
                     f"jd={jd}, date={date}, ndate={ndate}",
                 )
Example #3
0
def decodeBglBinTime(b_value):
    jd1970 = gregorian.to_jd(1970, 1, 1)
    djd, hm = divmod(binStrToInt(b_value), 24 * 60)
    year, month, day = gregorian.jd_to(djd + jd1970)
    hour, minute = divmod(hm, 60)
    return "%.2d/%.2d/%.2d, %.2d:%.2d" % (year, month, day, hour, minute)
Example #4
0
def decodeBglBinTime(b_value):
	jd1970 = gregorian.to_jd(1970, 1, 1)
	djd, hm = divmod(binStrToInt(b_value), 24*60)
	year, month, day = gregorian.jd_to(djd + jd1970)
	hour, minute = divmod(hm, 60)
	return "%.2d/%.2d/%.2d, %.2d:%.2d" % (year, month, day, hour, minute)
Example #5
0
def decodeBglBinTime(b_value):
    jd1970 = gregorian.to_jd(1970, 1, 1)
    djd, hm = divmod(binStrToInt(b_value), 24 * 60)
    year, month, day = gregorian.jd_to(djd + jd1970)
    hour, minute = divmod(hm, 60)
    return f"{year:04d}/{month:02d}/{day:02d}, {hour:02d}:{minute:02d}"
Example #6
0
def getMonthLen(y: int, m: int) -> int:
    if m == 12:
        return gregorian.to_jd(y + 1, 1, 1) - gregorian.to_jd(y, 12, 1)
    else:
        return gregorian.to_jd(y, m + 1, 1) - gregorian.to_jd(y, m, 1)