예제 #1
0
 def exportToIcs(self, fileName, startJd, endJd):
     currentTimeStamp = strftime(icsTmFormat)
     icsText = icsHeader
     for jd in range(startJd, endJd):
         isHoliday = False
         for mode in self.holidays.keys():
             myear, mmonth, mday = jd_to(jd, mode)
             if (mmonth, mday) in self.holidays[mode]:
                 isHoliday = True
                 break
         if isHoliday:
             gyear, gmonth, gday = jd_to(jd, DATE_GREG)
             gyear_next, gmonth_next, gday_next = jd_to(jd+1, DATE_GREG)
             #######
             icsText += 'BEGIN:VEVENT\n'
             icsText += 'CREATED:%s\n'%currentTimeStamp
             icsText += 'LAST-MODIFIED:%s\n'%currentTimeStamp
             icsText += 'DTSTART;VALUE=DATE:%.4d%.2d%.2d\n'%(gyear, gmonth, gday)
             icsText += 'DTEND;VALUE=DATE:%.4d%.2d%.2d\n'%(gyear_next, gmonth_next, gday_next)
             icsText += 'CATEGORIES:Holidays\n'
             icsText += 'TRANSP:TRANSPARENT\n'
             ## TRANSPARENT because being in holiday time, does not make you busy!
             ## see http://www.kanzaki.com/docs/ical/transp.html
             icsText += 'SUMMARY:%s\n'%_('Holiday')
             icsText += 'END:VEVENT\n'
     icsText += 'END:VCALENDAR\n'
     open(fileName, 'w').write(icsText)
예제 #2
0
def convertBuiltinTextPlugToIcs(plug, startJd, endJd, namePostfix=''):
    plug.load()  ## FIXME
    mode = plug.mode
    icsText = icsHeader
    currentTimeStamp = strftime(icsTmFormat)
    for jd in range(startJd, endJd):
        myear, mmonth, mday = jd_to(jd, mode)
        dayText = plug.get_text(myear, mmonth, mday)
        if dayText:
            gyear, gmonth, gday = jd_to(jd, DATE_GREG)
            gyear_next, gmonth_next, gday_next = jd_to(jd + 1, DATE_GREG)
            #######
            icsText += 'BEGIN:VEVENT\n'
            icsText += 'CREATED:%s\n' % currentTimeStamp
            icsText += 'LAST-MODIFIED:%s\n' % currentTimeStamp
            icsText += 'DTSTART;VALUE=DATE:%.4d%.2d%.2d\n' % (gyear, gmonth,
                                                              gday)
            icsText += 'DTEND;VALUE=DATE:%.4d%.2d%.2d\n' % (
                gyear_next, gmonth_next, gday_next)
            icsText += 'SUMMARY:%s\n' % dayText
            icsText += 'END:VEVENT\n'
    icsText += 'END:VCALENDAR\n'
    fname = split(plug.fpath)[-1]
    fname = splitext(fname)[0] + '%s.ics' % namePostfix
    open(fname, 'w').write(icsText)
예제 #3
0
파일: ics.py 프로젝트: ilius/starcal
def convertBuiltinTextPlugToIcs(plug, startJd, endJd, namePostfix=""):
	plug.load() ## FIXME
	mode = plug.mode
	icsText = icsHeader
	currentTimeStamp = strftime(icsTmFormat)
	for jd in range(startJd, endJd):
		myear, mmonth, mday = jd_to(jd, mode)
		dayText = plug.getText(myear, mmonth, mday)
		if dayText:
			gyear, gmonth, gday = jd_to(jd, DATE_GREG)
			gyear_next, gmonth_next, gday_next = jd_to(jd + 1, DATE_GREG)
			#######
			icsText += "\n".join([
				"BEGIN:VEVEN",
				"CREATED:%s" % currentTimeStamp,
				"LAST-MODIFIED:%s" % currentTimeStamp,
				"DTSTART;VALUE=DATE:%.4d%.2d%.2d" % (
					gyear,
					gmonth,
					gday,
				),
				"DTEND;VALUE=DATE:%.4d%.2d%.2d" % (
					gyear_next,
					gmonth_next,
					gday_next,
				),
				"SUMMARY:%s" % dayText,
				"END:VEVENT",
			]) + "\n"
	icsText += "END:VCALENDAR\n"
	fname = split(plug.fpath)[-1]
	fname = splitext(fname)[0] + "%s.ics" % namePostfix
	open(fname, "w").write(icsText)
예제 #4
0
파일: plugin_man.py 프로젝트: ilius/starcal
	def exportToIcs(self, fileName, startJd, endJd):
		currentTimeStamp = strftime(icsTmFormat)
		self.load()  # FIXME
		mode = self.mode
		icsText = icsHeader
		for jd in range(startJd, endJd):
			myear, mmonth, mday = jd_to(jd, mode)
			dayText = self.getText(myear, mmonth, mday)
			if dayText:
				gyear, gmonth, gday = jd_to(jd, DATE_GREG)
				gyear_next, gmonth_next, gday_next = jd_to(jd + 1, DATE_GREG)
				#######
				icsText += "\n".join([
					"BEGIN:VEVENT",
					"CREATED:%s" % currentTimeStamp,
					"LAST-MODIFIED:%s" % currentTimeStamp,
					"DTSTART;VALUE=DATE:%.4d%.2d%.2d" % (
						gyear,
						gmonth,
						gday,
					),
					"DTEND;VALUE=DATE:%.4d%.2d%.2d" % (
						gyear_next,
						gmonth_next,
						gday_next,
					),
					"SUMMARY:%s" % dayText,
					"END:VEVENT",
				]) + "\n"
		icsText += "END:VCALENDAR\n"
		open(fileName, "w", encoding="utf-8").write(icsText)
예제 #5
0
파일: ics.py 프로젝트: goodosuser/starcal
def convertHolidayPlugToIcs(plug, startJd, endJd, namePostfix=''):
    icsText = icsHeader
    currentTimeStamp = strftime(icsTmFormat)
    for jd in range(startJd, endJd):
        isHoliday = False
        for mode in plug.holidays.keys():
            myear, mmonth, mday = jd_to(jd, mode)
            if (mmonth, mday) in plug.holidays[mode]:
                isHoliday = True
                break
        if isHoliday:
            gyear, gmonth, gday = jd_to(jd, DATE_GREG)
            gyear_next, gmonth_next, gday_next = jd_to(jd+1, DATE_GREG)
            #######
            icsText += 'BEGIN:VEVENT\n'
            icsText += 'CREATED:%s\n'%currentTimeStamp
            icsText += 'LAST-MODIFIED:%s\n'%currentTimeStamp
            icsText += 'DTSTART;VALUE=DATE:%.4d%.2d%.2d\n'%(gyear, gmonth, gday)
            icsText += 'DTEND;VALUE=DATE:%.4d%.2d%.2d\n'%(gyear_next, gmonth_next, gday_next)
            icsText += 'CATEGORIES:Holidays\n'
            icsText += 'TRANSP:TRANSPARENT\n'
            ## TRANSPARENT because being in holiday time, does not make you busy!
            ## see http://www.kanzaki.com/docs/ical/transp.html
            icsText += 'SUMMARY:%s\n'%_('Holiday')
            icsText += 'END:VEVENT\n'
    icsText += 'END:VCALENDAR\n'
    fname = split(plug.fpath)[-1]
    fname = splitext(fname)[0] + '%s.ics'%namePostfix
    open(fname, 'w').write(icsText)
예제 #6
0
 def exportToIcs(self, fileName, startJd, endJd):
     currentTimeStamp = strftime(icsTmFormat)
     icsText = icsHeader
     for jd in range(startJd, endJd):
         isHoliday = False
         for mode in self.holidays.keys():
             myear, mmonth, mday = jd_to(jd, mode)
             if (mmonth, mday) in self.holidays[mode]:
                 isHoliday = True
                 break
         if isHoliday:
             gyear, gmonth, gday = jd_to(jd, DATE_GREG)
             gyear_next, gmonth_next, gday_next = jd_to(jd + 1, DATE_GREG)
             #######
             icsText += 'BEGIN:VEVENT\n'
             icsText += 'CREATED:%s\n' % currentTimeStamp
             icsText += 'LAST-MODIFIED:%s\n' % currentTimeStamp
             icsText += 'DTSTART;VALUE=DATE:%.4d%.2d%.2d\n' % (gyear,
                                                               gmonth, gday)
             icsText += 'DTEND;VALUE=DATE:%.4d%.2d%.2d\n' % (
                 gyear_next, gmonth_next, gday_next)
             icsText += 'CATEGORIES:Holidays\n'
             icsText += 'TRANSP:TRANSPARENT\n'
             ## TRANSPARENT because being in holiday time, does not make you busy!
             ## see http://www.kanzaki.com/docs/ical/transp.html
             icsText += 'SUMMARY:%s\n' % _('Holiday')
             icsText += 'END:VEVENT\n'
     icsText += 'END:VCALENDAR\n'
     open(fileName, 'w').write(icsText)
예제 #7
0
 def updateWidget(self):  ## FIXME
     common.WidgetClass.updateWidget(self)
     mode = self.event.mode
     ###
     self.startDateInput.set_value(jd_to(self.event.getStartJd(), mode))
     self.weeksSpin.set_value(self.event['cycleWeeks'].weeks)
     self.endDateInput.set_value(jd_to(self.event.getEndJd(), mode))
     ###
     timeRangeRule = self.event['dayTimeRange']
     self.dayTimeStartInput.set_value(timeRangeRule.dayTimeStart)
     self.dayTimeEndInput.set_value(timeRangeRule.dayTimeEnd)
예제 #8
0
파일: weekly.py 프로젝트: greyzero/starcal
 def updateWidget(self):## FIXME
     common.WidgetClass.updateWidget(self)
     mode = self.event.mode
     ###
     self.startDateInput.set_value(jd_to(self.event.getStartJd(), mode))
     self.weeksSpin.set_value(self.event['cycleWeeks'].weeks)
     self.endDateInput.set_value(jd_to(self.event.getEndJd(), mode))
     ###
     timeRangeRule = self.event['dayTimeRange']
     self.dayTimeStartInput.set_value(timeRangeRule.dayTimeStart)
     self.dayTimeEndInput.set_value(timeRangeRule.dayTimeEnd)
예제 #9
0
	def updateWidget(self):## FIXME
		common.WidgetClass.updateWidget(self)
		mode = self.event.mode
		###
		self.startDateInput.set_value(jd_to(self.event.getStartJd(), mode))
		self.endDateInput.set_value(jd_to(self.event.getEndJd(), mode))
		###
		self.daySpin.set_value(self.event.getDay())
		###
		dayTimeRange, ok = self.event["dayTimeRange"]
		if not ok:
			raise RuntimeError("no dayTimeRange rule")
		self.dayTimeStartInput.set_value(dayTimeRange.dayTimeStart)
		self.dayTimeEndInput.set_value(dayTimeRange.dayTimeEnd)
예제 #10
0
 def updateEndDates(self):
     y, m, d = self.startDateInput.get_value()
     jd0 = to_jd(y, m, d, self.altMode) - 1
     for row in self.trees:
         mLen = row[3]
         jd0 += mLen
         row[4] = dateLocale(*jd_to(jd0, self.altMode))
예제 #11
0
 def updateWidget(self):
     #for index, module in calTypes.iterIndexModule():
     #    if module.name != 'hijri':
     for mode in calTypes.active:
         modeDesc = calTypes[mode].desc
         if not 'hijri' in modeDesc.lower():
             self.altMode = mode
             self.altModeDesc = modeDesc
             break
     self.topLabel.set_label(_('Start')+': '+dateLocale(*monthDb.startDate)+' '+_('Equals to')+' %s'%_(self.altModeDesc))
     self.startDateInput.set_value(jd_to(monthDb.startJd, self.altMode))
     ###########
     selectYm = getCurrentYm() - 1 ## previous month
     selectIndex = None
     self.trees.clear()
     for index, ym, mLen in monthDb.getMonthLenList():
         if ym == selectYm:
             selectIndex = index
         year, month0 = divmod(ym, 12)
         self.trees.append([
             ym,
             _(year),
             _(monthName[month0]),
             mLen,
             '',
         ])
     self.updateEndDates()
     ########
     if selectIndex is not None:
         self.treev.scroll_to_cell(str(selectIndex))
         self.treev.set_cursor(str(selectIndex))
예제 #12
0
파일: ui.py 프로젝트: ilius/starcal
 def __init__(self, jd):
     self.eventsData = []
     # self.eventsDataIsSet = False ## not used
     self.pluginsText = ""
     ###
     self.jd = jd
     date = core.jd_to_primary(jd)
     self.year, self.month, self.day = date
     self.weekDay = core.jwday(jd)
     self.weekNum = core.getWeekNumber(self.year, self.month, self.day)
     # self.weekNumNeg = self.weekNum + 1 - core.getYearWeeksCount(self.year)
     self.weekNumNeg = self.weekNum - int(calTypes.primaryModule().avgYearLen / 7)
     self.holiday = self.weekDay in core.holidayWeekDays
     ###################
     self.dates = [date if mode == calTypes.primary else jd_to(jd, mode) for mode in range(len(calTypes))]
     """
     self.dates = dict([
         (
             mode, date if mode==calTypes.primary else jd_to(jd, mode)
         )
         for mode in calTypes.active
     ])
     """
     ###################
     for k in core.plugIndex:
         plug = core.allPlugList[k]
         if plug:
             try:
                 plug.update_cell(self)
             except:
                 myRaiseTback()
     ###################
     # t0 = now()
     self.eventsData = event_lib.getDayOccurrenceData(jd, eventGroups)  ## here? FIXME
예제 #13
0
 def updateWidget(self):## FIXME
     common.WidgetClass.updateWidget(self)
     mode = self.event.mode
     ###
     startJd = self.event.getJd()
     self.startDateInput.set_value(jd_to(startJd, mode))
     ###
     endType, endValue = self.event.getEnd()
     if endType=='duration':
         self.endTypeCombo.set_active(0)
         self.durationSpin.set_value(endValue)
         self.endDateInput.set_value(jd_to(self.event.getEndJd(), mode))## FIXME
     elif endType=='date':
         self.endTypeCombo.set_active(1)
         self.endDateInput.set_value(endValue)
     else:
         raise RuntimeError
     self.endTypeComboChanged()
예제 #14
0
 def updateWidget(self):  ## FIXME
     common.WidgetClass.updateWidget(self)
     mode = self.event.mode
     ###
     startJd = self.event.getJd()
     self.startDateInput.set_value(jd_to(startJd, mode))
     ###
     endType, endValue = self.event.getEnd()
     if endType == 'duration':
         self.endTypeCombo.set_active(0)
         self.durationSpin.set_value(endValue)
         self.endDateInput.set_value(jd_to(self.event.getEndJd(),
                                           mode))  ## FIXME
     elif endType == 'date':
         self.endTypeCombo.set_active(1)
         self.endDateInput.set_value(endValue)
     else:
         raise RuntimeError
     self.endTypeComboChanged()
예제 #15
0
파일: plugin_man.py 프로젝트: ilius/starcal
	def exportToIcs(self, fileName, startJd, endJd):
		currentTimeStamp = strftime(icsTmFormat)
		icsText = icsHeader
		for jd in range(startJd, endJd):
			isHoliday = False
			for mode in self.holidays.keys():
				myear, mmonth, mday = jd_to(jd, mode)
				if (mmonth, mday) in self.holidays[mode]:
					isHoliday = True
					break
				if (myear, mmonth, mday) in self.holidays[mode]:
					isHoliday = True
					break
			if isHoliday:
				gyear, gmonth, gday = jd_to(jd, DATE_GREG)
				gyear_next, gmonth_next, gday_next = jd_to(jd + 1, DATE_GREG)
				#######
				icsText += "\n".join([
					"BEGIN:VEVENT"
					"CREATED:%s" % currentTimeStamp,
					"LAST-MODIFIED:%s" % currentTimeStamp,
					"DTSTART;VALUE=DATE:%.4d%.2d%.2d" % (
						gyear,
						gmonth,
						gday,
					),
					"DTEND;VA0LUE=DATE:%.4d%.2d%.2d" % (
						gyear_next,
						gmonth_next,
						gday_next,
					),
					"CATEGORIES:Holidays",
					"TRANSP:TRANSPARENT",
					# TRANSPARENT because being in holiday time,
					# does not make you busy!
					# see http://www.kanzaki.com/docs/ical/transp.html
					"SUMMARY:%s" % _("Holiday"),
					"END:VEVENT",
				])
		icsText += "END:VCALENDAR\n"
		open(fileName, "w", encoding="utf-8").write(icsText)
예제 #16
0
 def exportToIcs(self, fileName, startJd, endJd):
     currentTimeStamp = strftime(icsTmFormat)
     self.load() ## FIXME
     mode = self.mode
     icsText = icsHeader
     for jd in range(startJd, endJd):
         myear, mmonth, mday = jd_to(jd, mode)
         dayText = self.get_text(myear, mmonth, mday)
         if dayText:
             gyear, gmonth, gday = jd_to(jd, DATE_GREG)
             gyear_next, gmonth_next, gday_next = jd_to(jd+1, DATE_GREG)
             #######
             icsText += 'BEGIN:VEVENT\n'
             icsText += 'CREATED:%s\n'%currentTimeStamp
             icsText += 'LAST-MODIFIED:%s\n'%currentTimeStamp
             icsText += 'DTSTART;VALUE=DATE:%.4d%.2d%.2d\n'%(gyear, gmonth, gday)
             icsText += 'DTEND;VALUE=DATE:%.4d%.2d%.2d\n'%(gyear_next, gmonth_next, gday_next)
             icsText += 'SUMMARY:%s\n'%dayText
             icsText += 'END:VEVENT\n'
     icsText += 'END:VCALENDAR\n'
     open(fileName, 'w').write(icsText)
예제 #17
0
 def exportToIcs(self, fileName, startJd, endJd):
     currentTimeStamp = strftime(icsTmFormat)
     self.load()  ## FIXME
     mode = self.mode
     icsText = icsHeader
     for jd in range(startJd, endJd):
         myear, mmonth, mday = jd_to(jd, mode)
         dayText = self.get_text(myear, mmonth, mday)
         if dayText:
             gyear, gmonth, gday = jd_to(jd, DATE_GREG)
             gyear_next, gmonth_next, gday_next = jd_to(jd + 1, DATE_GREG)
             #######
             icsText += 'BEGIN:VEVENT\n'
             icsText += 'CREATED:%s\n' % currentTimeStamp
             icsText += 'LAST-MODIFIED:%s\n' % currentTimeStamp
             icsText += 'DTSTART;VALUE=DATE:%.4d%.2d%.2d\n' % (gyear,
                                                               gmonth, gday)
             icsText += 'DTEND;VALUE=DATE:%.4d%.2d%.2d\n' % (
                 gyear_next, gmonth_next, gday_next)
             icsText += 'SUMMARY:%s\n' % dayText
             icsText += 'END:VEVENT\n'
     icsText += 'END:VCALENDAR\n'
     open(fileName, 'w').write(icsText)
예제 #18
0
 def update_cell(self, c):
     if not c.holiday:
         for mode in self.holidays:
             y, m, d = c.dates[mode]
             for hm, hd in self.holidays[mode]:
                 if m==hm:
                     if d==hd:
                         c.holiday = True
                         break
                     elif self.lastDayMerge and d==hd-1 and hd>=calTypes[mode].minMonthLen:
                         ny, nm, nd = jd_to(c.jd+1, mode)
                         if (ny, nm) > (y, m):
                             c.holiday = True
                             break
예제 #19
0
파일: ics.py 프로젝트: greyzero/starcal
def convertBuiltinTextPlugToIcs(plug, startJd, endJd, namePostfix=''):
    plug.load() ## FIXME
    mode = plug.mode
    icsText = icsHeader
    currentTimeStamp = strftime(icsTmFormat)
    for jd in range(startJd, endJd):
        myear, mmonth, mday = jd_to(jd, mode)
        dayText = plug.get_text(myear, mmonth, mday)
        if dayText:
            gyear, gmonth, gday = jd_to(jd, DATE_GREG)
            gyear_next, gmonth_next, gday_next = jd_to(jd+1, DATE_GREG)
            #######
            icsText += 'BEGIN:VEVENT\n'
            icsText += 'CREATED:%s\n'%currentTimeStamp
            icsText += 'LAST-MODIFIED:%s\n'%currentTimeStamp
            icsText += 'DTSTART;VALUE=DATE:%.4d%.2d%.2d\n'%(gyear, gmonth, gday)
            icsText += 'DTEND;VALUE=DATE:%.4d%.2d%.2d\n'%(gyear_next, gmonth_next, gday_next)
            icsText += 'SUMMARY:%s\n'%dayText
            icsText += 'END:VEVENT\n'
    icsText += 'END:VCALENDAR\n'
    fname = split(plug.fpath)[-1]
    fname = splitext(fname)[0] + '%s.ics'%namePostfix
    open(fname, 'w').write(icsText)
예제 #20
0
 def update_cell(self, c):
     if not c.holiday:
         for mode in self.holidays:
             y, m, d = c.dates[mode]
             for hm, hd in self.holidays[mode]:
                 if m == hm:
                     if d == hd:
                         c.holiday = True
                         break
                     elif self.lastDayMerge and d == hd - 1 and hd >= calTypes[
                             mode].minMonthLen:
                         ny, nm, nd = jd_to(c.jd + 1, mode)
                         if (ny, nm) > (y, m):
                             c.holiday = True
                             break
예제 #21
0
 def update_cell(self, c):
     y, m, d = c.dates[self.mode]
     text = ''
     t = self.get_text(y, m, d)
     if t:
         text += t
     if self.lastDayMerge and d>=calTypes[self.mode].minMonthLen:
     ## and d<=calTypes[self.mode].maxMonthLen:
         ny, nm, nd = jd_to(c.jd + 1, self.mode)
         if nm > m or ny > y:
             nt = self.get_text(y, m, d+1)
             if nt:
                 text += nt
     if text:
         if c.pluginsText:
             c.pluginsText += '\n'
         c.pluginsText += text
예제 #22
0
 def update_cell(self, c):
     y, m, d = c.dates[self.mode]
     text = ''
     t = self.get_text(y, m, d)
     if t:
         text += t
     if self.lastDayMerge and d >= calTypes[self.mode].minMonthLen:
         ## and d<=calTypes[self.mode].maxMonthLen:
         ny, nm, nd = jd_to(c.jd + 1, self.mode)
         if nm > m or ny > y:
             nt = self.get_text(y, m, d + 1)
             if nt:
                 text += nt
     if text:
         if c.pluginsText:
             c.pluginsText += '\n'
         c.pluginsText += text
예제 #23
0
	def __init__(self, jd):
		self.eventsData = []
		# self.eventsDataIsSet = False  # not used
		self.pluginsText = ""
		###
		self.jd = jd
		date = core.jd_to_primary(jd)
		self.year, self.month, self.day = date
		self.weekDay = core.jwday(jd)
		self.weekNum = core.getWeekNumber(self.year, self.month, self.day)
		# self.weekNumNeg = self.weekNum+1 - core.getYearWeeksCount(self.year)
		self.weekNumNeg = self.weekNum - int(
			calTypes.primaryModule().avgYearLen / 7
		)
		self.holiday = (self.weekDay in core.holidayWeekDays)
		###################
		self.dates = [
			date if mode == calTypes.primary else jd_to(jd, mode)
			for mode in range(len(calTypes))
		]
		"""
		self.dates = dict([
			(
				mode, date if mode==calTypes.primary else jd_to(jd, mode)
			)
			for mode in calTypes.active
		])
		"""
		###################
		for k in core.plugIndex:
			plug = core.allPlugList[k]
			if plug:
				try:
					plug.updateCell(self)
				except:
					myRaiseTback()
		###################
		# t0 = now()
		self.eventsData = event_lib.getDayOccurrenceData(
			jd,
			eventGroups,
		)  # here? FIXME
		"""
예제 #24
0
파일: hijri.py 프로젝트: ilius/starcal
	def updateWidget(self):
		#for index, module in calTypes.iterIndexModule():
		#	if module.name != "hijri":
		for mode in calTypes.active:
			module, ok = calTypes[mode]
			if not ok:
				raise RuntimeError("cal type %r not found" % mode)
			modeDesc = module.desc
			if "hijri" not in modeDesc.lower():
				self.altMode = mode
				self.altModeDesc = modeDesc
				break
		self.topLabel.set_label(
			_("Start") +
			": " +
			dateLocale(*hijri.monthDb.startDate) +
			" " +
			_("Equals to") +
			" %s" % _(self.altModeDesc)
		)
		self.startDateInput.set_value(jd_to(hijri.monthDb.startJd, self.altMode))
		###########
		selectYm = getCurrentYm() - 1 ## previous month
		selectIndex = None
		self.trees.clear()
		for index, ym, mLen in hijri.monthDb.getMonthLenList():
			if ym == selectYm:
				selectIndex = index
			year, month0 = divmod(ym, 12)
			self.trees.append([
				ym,
				_(year),
				_(hijri.monthName[month0]),
				mLen,
				"",
			])
		self.updateEndDates()
		########
		if selectIndex is not None:
			self.treev.scroll_to_cell(str(selectIndex))
			self.treev.set_cursor(str(selectIndex))
예제 #25
0
class DateButton(MultiSpinButton):
    def __init__(self, date=None, **kwargs):
        MultiSpinButton.__init__(self, '/', (
            YearField(),
            MonthField(),
            DayField(),
        ), **kwargs)
        if date == None:
            date = localtime()[:3]
        self.set_value(date)

    def get_jd(self, mode):
        y, m, d = self.get_value()
        return to_jd(y, m, d, mode)

    changeMode = lambda self, fromMode, toMode: self.set_value(
        jd_to(self.get_jd(fromMode), toMode))

    def setMaxDay(self, _max):
        self.field.children[2].setMax(_max)
        self.update()
예제 #26
0
파일: plugin_man.py 프로젝트: ilius/starcal
	def updateCell(self, c):
		module, ok = calTypes[self.mode]
		if not ok:
			raise RuntimeError("cal type %r not found" % self.mode)

		y, m, d = c.dates[self.mode]
		text = ""
		t = self.getText(y, m, d)
		if t:
			text += t
		if self.lastDayMerge and d >= module.minMonthLen:
			# and d <= module.maxMonthLen:
			ny, nm, nd = jd_to(c.jd + 1, self.mode)
			if nm > m or ny > y:
				nt = self.getText(y, m, d + 1)
				if nt:
					text += nt
		if text:
			if c.pluginsText:
				c.pluginsText += "\n"
			c.pluginsText += text
예제 #27
0
파일: plugin_man.py 프로젝트: ilius/starcal
	def dateIsHoliday(self, mode, y, m, d, jd):
		module, ok = calTypes[mode]
		if not ok:
			raise RuntimeError("cal type %r not found" % mode)

		for item in self.holidays[mode]:
			if len(item) == 2:
				hm, hd = item
				hy = None
			elif len(item) == 3:
				hy, hm, hd = item
			else:
				log.error("bad holiday item %r" % item)
				continue

			if hy is not None and hy != y:
				continue

			if hm != m:
				continue

			if d == hd:
				return True

			if (
				hy is None
				and
				self.lastDayMerge
				and
				d == hd - 1
				and
				hd >= module.minMonthLen
			):
				ny, nm, nd = jd_to(jd + 1, mode)
				if (ny, nm) > (y, m):
					return True

		return False
예제 #28
0
 def updateWidget(self):
     #for index, module in calTypes.iterIndexModule():
     #	if module.name != "hijri":
     for mode in calTypes.active:
         module, ok = calTypes[mode]
         if not ok:
             raise RuntimeError("cal type %r not found" % mode)
         modeDesc = module.desc
         if "hijri" not in modeDesc.lower():
             self.altMode = mode
             self.altModeDesc = modeDesc
             break
     self.topLabel.set_label(
         _("Start") + ": " + dateLocale(*hijri.monthDb.startDate) + " " +
         _("Equals to") + " %s" % _(self.altModeDesc))
     self.startDateInput.set_value(
         jd_to(hijri.monthDb.startJd, self.altMode))
     ###########
     selectYm = getCurrentYm() - 1  ## previous month
     selectIndex = None
     self.trees.clear()
     for index, ym, mLen in hijri.monthDb.getMonthLenList():
         if ym == selectYm:
             selectIndex = index
         year, month0 = divmod(ym, 12)
         self.trees.append([
             ym,
             _(year),
             _(hijri.monthName[month0]),
             mLen,
             "",
         ])
     self.updateEndDates()
     ########
     if selectIndex is not None:
         self.treev.scroll_to_cell(str(selectIndex))
         self.treev.set_cursor(str(selectIndex))
예제 #29
0
파일: date.py 프로젝트: ilius/starcal
	def changeMode(self, fromMode, toMode):
		self.set_value(jd_to(
			self.get_jd(fromMode),
			toMode,
		))
예제 #30
0
 def onDraw(self, widget=None, event=None):
     cr = self.get_window().cairo_create()
     width = float(self.get_allocation().width)
     height = float(self.get_allocation().height)
     dia = min(width, height)
     maxR = float(dia) / 2.0
     minR = self.innerCircleRatio * maxR
     x0 = (width - dia) / 2.0
     y0 = (height - dia) / 2.0
     cx = x0 + maxR
     cy = y0 + maxR
     ####
     #self.angleOffset
     #self.bgColor
     #self.wheelBgColor
     #self.lineColor
     #self.lineWidth
     #self.textColor
     ####
     cr.rectangle(0, 0, width, height)
     fillColor(cr, self.bgColor)
     ####
     calsN = len(calTypes.active)
     deltaR = (maxR - minR) / float(calsN)
     mode0 = calTypes.active[0]
     jd0 = to_jd(ui.todayCell.year, 1, 1, mode0)
     yearLen = calTypes.primaryModule().avgYearLen
     angle0 = self.angleOffset * pi / 180.0 - pi / 2.0
     avgDeltaAngle = 2 * pi / 12
     ####
     if self.todayIndicatorEnable:
         drawLineLengthAngle(
             cr,
             cx,
             cy,
             maxR,  ## FIXME
             angle0 + 2.0 * pi * (ui.todayCell.jd - jd0) / yearLen,
             self.todayIndicatorWidth,
         )
         fillColor(cr, self.todayIndicatorColor)
     ####
     drawCircle(cr, cx, cy, self.centerR)
     fillColor(cr, self.centerColor)
     ####
     drawCircleOutline(cr, cx, cy, maxR, maxR - minR)
     fillColor(cr, self.wheelBgColor)
     ####
     spinngJd = getSpringJdAfter(jd0)
     springAngle = angle0 + 2.0 * pi * (spinngJd -
                                        jd0) / yearLen  ## radians
     for index, color in enumerate((
             self.springColor,
             self.summerColor,
             self.autumnColor,
             self.winterColor,
     )):
         drawArcOutline(
             cr,
             cx,
             cy,
             maxR,
             maxR - minR,
             springAngle + index * pi / 2.0,
             springAngle + (index + 1) * pi / 2.0,
         )
         fillColor(cr, color)
     ####
     for index, mode in enumerate(calTypes.active):
         dr = index * deltaR
         r = maxR - dr
         cx0 = x0 + dr
         cy0 = y0 + dr
         ###
         drawCircleOutline(cr, cx, cy, r, self.lineWidth)
         fillColor(cr, self.lineColor)
         ####
         year0, month0, day0 = jd_to(jd0, mode)
         ym0 = year0 * 12 + (month0 - 1)
         cr.set_line_width(self.lineWidth)
         for ym in range(ym0, ym0 + 12):
             year, month = divmod(ym, 12)
             month += 1
             jd = to_jd(year, month, 1, mode)
             angle = angle0 + 2.0 * pi * (jd - jd0) / yearLen  ## radians
             #angleD = angle * 180 / pi
             #print('mode=%s, year=%s, month=%s, angleD=%.1f'%(mode, year, month, angleD))
             d = self.lineWidth
             sepX, sepY = goAngle(
                 cx,
                 cy,
                 angle,
                 r - d * 0.2,  ## FIXME
             )
             drawLineLengthAngle(
                 cr,
                 sepX,
                 sepY,
                 deltaR - d * 0.2,  ## FIXME
                 angle + pi,
                 d,
             )
             fillColor(
                 cr,
                 self.yearStartLineColor if month == 1 else self.lineColor,
             )
             ###
             layoutMaxW = (r - deltaR) * 2.0 * pi / 12.0
             layoutMaxH = deltaR
             layout = newTextLayout(
                 self,
                 text=getMonthName(mode, month, year),
                 maxSize=(layoutMaxW, layoutMaxH),
                 maximizeScale=0.6,
                 truncate=False,
             )
             layoutW, layoutH = layout.get_pixel_size()
             centerAngle = angle + avgDeltaAngle / 2.0
             lx, ly = goAngle(
                 cx,
                 cy,
                 centerAngle,
                 (r - deltaR / 3.0),
             )
             lx, ly = goAngle(
                 lx,
                 ly,
                 angle - pi / 2.0,
                 layoutW / 2.0,
             )
             lx, ly = goAngle(
                 lx,
                 ly,
                 angle,
                 layoutH / 2.0,
             )
             cr.move_to(
                 lx,
                 ly,
             )
             #cr.save()
             rotateAngle = centerAngle + pi / 2.0
             cr.rotate(rotateAngle)
             setColor(cr, self.textColor)
             show_layout(cr, layout)
             cr.rotate(-rotateAngle)
             #cr.restore()
         #####
         drawCircleOutline(cr, cx, cy, minR, self.lineWidth)
         fillColor(cr, self.lineColor)
예제 #31
0
 def changeMode(self, fromMode, toMode):
     self.set_value(jd_to(
         self.get_jd(fromMode),
         toMode,
     ))
예제 #32
0
파일: ics.py 프로젝트: goodosuser/starcal
def getIcsDateByJd(jd, pretty=False):
    y, m, d = jd_to(jd, DATE_GREG)
    return getIcsDate(y, m, d, pretty)
예제 #33
0
	def onDraw(self, widget=None, event=None):
		cr = self.get_window().cairo_create()
		width = float(self.get_allocation().width)
		height = float(self.get_allocation().height)
		dia = min(width, height)
		maxR = float(dia) / 2.0
		minR = self.innerCircleRatio * maxR
		x0 = (width - dia) / 2.0
		y0 = (height - dia) / 2.0
		cx = x0 + maxR
		cy = y0 + maxR
		####
		#self.angleOffset
		#self.bgColor
		#self.wheelBgColor
		#self.lineColor
		#self.lineWidth
		#self.textColor
		####
		cr.rectangle(0, 0, width, height)
		fillColor(cr, self.bgColor)
		####
		calsN = len(calTypes.active)
		deltaR = (maxR - minR) / float(calsN)
		mode0 = calTypes.active[0]
		jd0 = to_jd(ui.todayCell.year, 1, 1, mode0)
		yearLen = calTypes.primaryModule().avgYearLen
		angle0 = self.angleOffset * pi / 180.0 - pi/2.0
		avgDeltaAngle = 2*pi / 12
		####
		if self.todayIndicatorEnable:
			drawLineLengthAngle(
				cr,
				cx,
				cy,
				maxR,## FIXME
				angle0 + 2.0*pi*(ui.todayCell.jd - jd0)/yearLen,
				self.todayIndicatorWidth,
			)
			fillColor(cr, self.todayIndicatorColor)
		####
		drawCircle(cr, cx, cy, self.centerR)
		fillColor(cr, self.centerColor)
		####
		drawCircleOutline(cr, cx, cy, maxR, maxR-minR)
		fillColor(cr, self.wheelBgColor)
		####
		spinngJd = getSpringJdAfter(jd0)
		springAngle = angle0 + 2.0*pi*(spinngJd - jd0)/yearLen ## radians
		for index, color in enumerate((
			self.springColor,
			self.summerColor,
			self.autumnColor,
			self.winterColor,
		)):
			drawArcOutline(
				cr,
				cx,
				cy,
				maxR,
				maxR-minR,
				springAngle + index * pi/2.0,
				springAngle + (index+1) * pi/2.0,
			)
			fillColor(cr, color)
		####
		for index, mode in enumerate(calTypes.active):
			dr = index * deltaR
			r = maxR - dr
			cx0 = x0 + dr
			cy0 = y0 + dr
			###
			drawCircleOutline(cr, cx, cy, r, self.lineWidth)
			fillColor(cr, self.lineColor)
			####
			year0, month0, day0 = jd_to(jd0, mode)
			ym0 = year0*12 + (month0-1)
			cr.set_line_width(self.lineWidth)
			for ym in range(ym0, ym0 + 12):
				year, month = divmod(ym, 12) ; month += 1
				jd = to_jd(year, month, 1, mode)
				angle = angle0 + 2.0*pi*(jd - jd0)/yearLen ## radians
				#angleD = angle * 180 / pi
				#print('mode=%s, year=%s, month=%s, angleD=%.1f'%(mode, year, month, angleD))
				d = self.lineWidth
				sepX, sepY = goAngle(
					cx,
					cy,
					angle,
					r - d*0.2,## FIXME
				)
				drawLineLengthAngle(
					cr,
					sepX,
					sepY,
					deltaR - d*0.2,## FIXME
					angle + pi,
					d,
				)
				fillColor(
					cr,
					self.yearStartLineColor if month==1 else self.lineColor,
				)
				###
				layoutMaxW = (r - deltaR) * 2.0 * pi / 12.0
				layoutMaxH = deltaR
				layout = newTextLayout(
					self,
					text=getMonthName(mode, month, year),
					maxSize=(layoutMaxW, layoutMaxH),
					maximizeScale=0.6,
					truncate=False,
				)
				layoutW, layoutH = layout.get_pixel_size()
				centerAngle = angle + avgDeltaAngle/2.0
				lx, ly = goAngle(
					cx,
					cy,
					centerAngle,
					(r - deltaR/3.0),
				)
				lx, ly = goAngle(
					lx,
					ly,
					angle - pi/2.0,
					layoutW / 2.0,
				)
				lx, ly = goAngle(
					lx,
					ly,
					angle,
					layoutH / 2.0,
				)
				cr.move_to(
					lx,
					ly,
				)
				#cr.save()
				rotateAngle = centerAngle + pi/2.0
				cr.rotate(rotateAngle)
				setColor(cr, self.textColor) ; show_layout(cr, layout)    
				cr.rotate(-rotateAngle)
				#cr.restore()
			#####
			drawCircleOutline(cr, cx, cy, minR, self.lineWidth)
			fillColor(cr, self.lineColor)