コード例 #1
0
ファイル: starcal2-daemon.py プロジェクト: karoon/starcal2
def prepareToday():
    tm = getCurrentTime()
    (y, m, d) = localtime(tm)[:3]
    #log.debug('Date: %s/%s/%s   Epoch: %s'%(y, m, d, tm))
    todayJd = to_jd(y, m, d, DATE_GREG)
    dayRemainSecondsCeil = int(-(tm - 1)%(24*3600))
    timeout_add_seconds(dayRemainSecondsCeil, prepareToday)
    for group in eventGroups:
        if not group.enable:
            continue
        for epoch0, epoch1, eid in group.node.getEvents(getEpochFromJd(todayJd), getEpochFromJd(todayJd+1)):
            event = group[eid]
            if not event.notifiers:
                continue
            dt = epoch0 - event.getNotifyBeforeSec() - tm
            if dt >= 0:
                timeout_add_seconds(int(dt)+1, notify, eid)
コード例 #2
0
ファイル: core.py プロジェクト: karoon/starcal2
def getJdFromWeek(year, weekNumber):## FIXME
    ## weekDay == 0
    wd0 = getWeekDay(year, 1, 1) - 1
    wn0 = getWeekNumber(year, 1, 1, False)
    jd0 = to_jd(year, 1, 1, primaryMode)
    return jd0 - wd0 + (weekNumber-wn0)*7
コード例 #3
0
ファイル: core.py プロジェクト: karoon/starcal2
def getJdRangeForMonth(year, month, mode):
    day = getMonthLen(year, month, mode)
    return (to_jd(year, month, 1, mode),
            to_jd(year, month, day, mode) + 1)
コード例 #4
0
ファイル: core.py プロジェクト: karoon/starcal2
def getCurrentJd():## time() and mktime(localtime()) both return GMT, not local
    (y, m, d) = localtime()[:3]
    return to_jd(y, m, d, DATE_GREG)
コード例 #5
0
ファイル: core.py プロジェクト: karoon/starcal2
from scal2.cal_modules import modules, moduleNames, modNum, jd_to, to_jd, convert, DATE_GREG


################################################################################
####################### class and function defenitions #########################
################################################################################

popen_output = lambda cmd: subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0]

primary_to_jd = lambda y, m, d: modules[primaryMode].to_jd(y, m, d)

def getCurrentJd():## time() and mktime(localtime()) both return GMT, not local
    (y, m, d) = localtime()[:3]
    return to_jd(y, m, d, DATE_GREG)

getEpochFromDate = lambda y, m, d, mode: getEpochFromJd(to_jd(y, m, d, mode))

def getWeekDateHmsFromEpoch(epoch):
   (jd, hour, minute, sec) = getJhmsFromEpoch(epoch)
   (absWeekNumber, weekDay) = getWeekDateFromJd(jd)
   return (absWeekNumber, weekDay, hour, minute, sec)

def getJdRangeForMonth(year, month, mode):
    day = getMonthLen(year, month, mode)
    return (to_jd(year, month, 1, mode),
            to_jd(year, month, day, mode) + 1)

def getFloatYearFromEpoch(epoch, mode):
    module = modules[mode]
    return float(epoch - module.epoch)/module.avgYearLen + 1
コード例 #6
0
ファイル: multi_spin_button.py プロジェクト: karoon/starcal2
 def get_jd(self, mode):
     y, m, d = self.get_value()
     return to_jd(y, m, d, mode)