def getUtcOffsetByJd(jd, tz=None): if not tz: tz = natz.gettz() tzStr = str(tz) # utcOffsetByJdCache: {tzStr => {jd => utcOffset}} if jd >= J1970: tzDict = utcOffsetByJdCache.get(tzStr) if tzDict is None: tzDict = utcOffsetByJdCache[tzStr] = {} offset = tzDict.get(jd) if offset is None: y, m, d = jd_to_g(jd) offset = tzDict[jd] = getUtcOffsetByGDate(y, m, d, tz) else: y, m, d = jd_to_g(jd) offset = getUtcOffsetByGDate(y, m, d, tz) return offset
def epochGregDateTimeEncode(epoch, tz=None): jd, hour, minute, second = getJhmsFromEpoch(epoch, tz) year, month, day = jd_to_g(jd) return "%.4d/%.2d/%.2d %.2d:%.2d:%.2d" % ( year, month, day, hour, minute, second, )
def getUtcOffsetByJd(jd, tz=None): y, m, d = jd_to_g(jd) return getUtcOffsetByGDate(y, m, d, tz)
def getEpochFromJd(jd, tz=None): localEpoch = (jd - J1970) * 24 * 3600 year, month, day = jd_to_g(jd) ## jd or jd-1? FIXME return localEpoch - getUtcOffsetByGDate(year, month, day, tz)
def getEpochFromJd(jd, tz=None): localEpoch = (jd - J1970) * 24 * 3600 year, month, day = jd_to_g(jd) # jd or jd-1? FIXME return localEpoch - getUtcOffsetByGDate(year, month, day, tz)