Example #1
0
	def get_times_jd(self, jd):
		times = self.backend.getTimesByJd(
			jd,
			getUtcOffsetByJd(jd, localTz) / 3600,
		)
		return [
			(name, times[name])
			for name in self.shownTimeNames
		]
Example #2
0
	def onCurrentDateChange(self, gdate):
		print("praytimes: onCurrentDateChange", gdate)
		if not self.enable:
			return
		jd = gregorian_to_jd(*tuple(gdate))
		#print(
		#	getUtcOffsetByJd(jd, localTz) / 3600,
		#	getUtcOffsetCurrent() / 3600,
		#)
		#utcOffset = getUtcOffsetCurrent()
		utcOffset = getUtcOffsetByJd(jd, localTz)
		tmUtc = now()
		epochLocal = tmUtc + utcOffset
		secondsFromMidnight = epochLocal % (24 * 3600)
		midnightUtc = tmUtc - secondsFromMidnight
		#print("------- hours from midnight", secondsFromMidnight/3600.0)
		for timeName, azanHour in self.backend.getTimesByJd(
			jd,
			utcOffset / 3600,
		).items():
			if timeName not in self.azanTimeNamesAll:
				continue
			if timeName not in self.shownTimeNames:
				continue
			azanSec = azanHour * 3600.0
			#####
			toAzanSecs = int(azanSec - secondsFromMidnight)
			if toAzanSecs >= 0:
				preAzanSec = azanSec - self.preAzanMinutes * 60
				toPreAzanSec = max(
					0,
					int(preAzanSec - secondsFromMidnight)
				)
				print("toPreAzanSec=%.1f" % toPreAzanSec)
				Timer(
					toPreAzanSec,
					self.doPlayPreAzan,
					#midnightUtc + preAzanSec,
				).start()
				###
				print("toAzanSecs=%.1f" % toAzanSecs)
				Timer(
					toAzanSecs,
					self.doPlayAzan,
					#midnightUtc + azanSec,
				).start()
Example #3
0
 def onCurrentDateChange(self, gdate):
     print("praytimes: onCurrentDateChange", gdate)
     if not self.enable:
         return
     jd = gregorian_to_jd(*tuple(gdate))
     #print(
     #	getUtcOffsetByJd(jd, localTz) / 3600,
     #	getUtcOffsetCurrent() / 3600,
     #)
     #utcOffset = getUtcOffsetCurrent()
     utcOffset = getUtcOffsetByJd(jd, localTz)
     tmUtc = now()
     epochLocal = tmUtc + utcOffset
     secondsFromMidnight = epochLocal % (24 * 3600)
     midnightUtc = tmUtc - secondsFromMidnight
     #print("------- hours from midnight", secondsFromMidnight/3600.0)
     for timeName, azanHour in self.backend.getTimesByJd(
             jd,
             utcOffset / 3600,
     ).items():
         if timeName not in self.azanTimeNamesAll:
             continue
         if timeName not in self.shownTimeNames:
             continue
         azanSec = azanHour * 3600.0
         #####
         toAzanSecs = int(azanSec - secondsFromMidnight)
         if toAzanSecs >= 0:
             preAzanSec = azanSec - self.preAzanMinutes * 60
             toPreAzanSec = max(0, int(preAzanSec - secondsFromMidnight))
             print("toPreAzanSec=%.1f" % toPreAzanSec)
             Timer(
                 toPreAzanSec,
                 self.doPlayPreAzan,
                 #midnightUtc + preAzanSec,
             ).start()
             ###
             print("toAzanSecs=%.1f" % toAzanSecs)
             Timer(
                 toAzanSecs,
                 self.doPlayAzan,
                 #midnightUtc + azanSec,
             ).start()
Example #4
0
 def get_times_jd(self, jd):
     times = self.backend.getTimesByJd(
         jd,
         getUtcOffsetByJd(jd) / 3600.0,
     )
     return [(name, times[name]) for name in self.shownTimeNames]
Example #5
0
	def drawAll(self, cr):
		timeStart = self.timeStart
		timeWidth = self.timeWidth
		timeEnd = timeStart + timeWidth
		####
		width = self.get_allocation().width
		height = self.get_allocation().height
		pixelPerSec = self.pixelPerSec
		dayPixel = dayLen * pixelPerSec ## pixel
		maxTickHeight = maxTickHeightRatio * height
		#####
		cr.rectangle(0, 0, width, height)
		fillColor(cr, bgColor)
		#####
		setColor(cr, holidayBgBolor)
		for x in self.data["holidays"]:
			cr.rectangle(x, 0, dayPixel, height)
			cr.fill()
		#####
		for tick in self.data["ticks"]:
			self.drawTick(cr, tick, maxTickHeight)
		######
		beforeBoxH = maxTickHeight ## FIXME
		maxBoxH = height - beforeBoxH
		for box in self.data["boxes"]:
			box.setPixelValues(timeStart, pixelPerSec, beforeBoxH, maxBoxH)
			self.drawBox(cr, box)
		self.drawBoxEditingHelperLines(cr)
		###### Show (possible) Daylight Saving change
		if timeStart > 0 and 2 * 3600 < timeWidth < 30 * dayLen:
			if getUtcOffsetByEpoch(timeStart) != getUtcOffsetByEpoch(timeEnd):
				startJd = getJdFromEpoch(timeStart)
				endJd = getJdFromEpoch(timeEnd)
				lastOffset = getUtcOffsetByJd(startJd, localTz)
				dstChangeJd = None
				deltaSec = 0
				for jd in range(startJd + 1, endJd + 1):
					offset = getUtcOffsetByJd(jd, localTz)
					deltaSec = offset - lastOffset
					if deltaSec != 0:
						dstChangeJd = jd
						break
				if dstChangeJd is not None:
					deltaHour = deltaSec / 3600.0
					dstChangeEpoch = getEpochFromJd(dstChangeJd)
					#print("dstChangeEpoch = %s" % dstChangeEpoch)
				else:
					print("dstChangeEpoch not found")

		###### Draw Current Time Marker
		dt = self.currentTime - timeStart
		if 0 <= dt <= timeWidth:
			setColor(cr, currentTimeMarkerColor)
			cr.rectangle(
				dt * pixelPerSec - currentTimeMarkerWidth / 2.0,
				0,
				currentTimeMarkerWidth,
				currentTimeMarkerHeightRatio * self.get_allocation().height
			)
			cr.fill()
		######
		for button in self.buttons:
			button.draw(cr, width, height)
Example #6
0
    def drawAll(self, cr):
        timeStart = self.timeStart
        timeWidth = self.timeWidth
        timeEnd = timeStart + timeWidth
        ####
        width = self.get_allocation().width
        height = self.get_allocation().height
        pixelPerSec = self.pixelPerSec
        dayPixel = dayLen * pixelPerSec  ## pixel
        maxTickHeight = maxTickHeightRatio * height
        #####
        cr.rectangle(0, 0, width, height)
        fillColor(cr, bgColor)
        #####
        setColor(cr, holidayBgBolor)
        for x in self.data["holidays"]:
            cr.rectangle(x, 0, dayPixel, height)
            cr.fill()
        #####
        for tick in self.data["ticks"]:
            self.drawTick(cr, tick, maxTickHeight)
        ######
        beforeBoxH = maxTickHeight  ## FIXME
        maxBoxH = height - beforeBoxH
        for box in self.data["boxes"]:
            box.setPixelValues(timeStart, pixelPerSec, beforeBoxH, maxBoxH)
            self.drawBox(cr, box)
        self.drawBoxEditingHelperLines(cr)
        ###### Show (possible) Daylight Saving change
        if timeStart > 0 and 2 * 3600 < timeWidth < 30 * dayLen:
            if getUtcOffsetByEpoch(timeStart) != getUtcOffsetByEpoch(timeEnd):
                startJd = getJdFromEpoch(timeStart)
                endJd = getJdFromEpoch(timeEnd)
                lastOffset = getUtcOffsetByJd(startJd, localTz)
                dstChangeJd = None
                deltaSec = 0
                for jd in range(startJd + 1, endJd + 1):
                    offset = getUtcOffsetByJd(jd, localTz)
                    deltaSec = offset - lastOffset
                    if deltaSec != 0:
                        dstChangeJd = jd
                        break
                if dstChangeJd is not None:
                    deltaHour = deltaSec / 3600.0
                    dstChangeEpoch = getEpochFromJd(dstChangeJd)
                    #print("dstChangeEpoch = %s" % dstChangeEpoch)
                else:
                    print("dstChangeEpoch not found")

        ###### Draw Current Time Marker
        dt = self.currentTime - timeStart
        if 0 <= dt <= timeWidth:
            setColor(cr, currentTimeMarkerColor)
            cr.rectangle(
                dt * pixelPerSec - currentTimeMarkerWidth / 2.0, 0,
                currentTimeMarkerWidth,
                currentTimeMarkerHeightRatio * self.get_allocation().height)
            cr.fill()
        ######
        for button in self.buttons:
            button.draw(cr, width, height)