Beispiel #1
0
def fetch_many_dilberts():
    d = jddate.FromToday()
    while 1:
        filename = "%s.gif" % d.GetString_YYYYMMDD()
        if os.path.exists(filename):
            print filename, "already present"
        else:
            try:
                fetch_dilbert(d, filename)
            except dilberterror:
                print "-- not a GIF file, aborting"
                return
        d = d - 1
Beispiel #2
0
    def __init__(self, year):
	self.year = year       # År (exv. 2004)
	self.jd_jan1 = JD(year, 1, 1)
	self.jd_dec31 = JD(year, 12, 31)

	# Skapa alla dagar för året
	self.days = []
        jd_today = jddate.FromToday()
	jd = self.jd_jan1
	while jd <= self.jd_dec31:
	    self.days.append(DayCal(jd, mark_as_today = (jd==jd_today)))
	    jd = jd + 1

	# Skottår?
	if len(self.days) == 365 or len(self.days) == 354:
	    self.leap_year = False
	elif len(self.days) == 366 or len(self.days) == 367:
	    self.leap_year = True
	else:
	    assert ValueError, "bad number of days in a year"

	# Helgdagar, flaggdagar med mera
	self.place_names()

	# Namnsdagar
	if year >= 2011:
		self.place_name_day_names("namnsdagar-2011.txt",
				      [(2015,  7, 23, ["Emma","Emmy"]),
				       (2015,  7, 26, ["Jesper","Jasmin"]),
				       (2018,  3,  8, ["Siv","Saga"]),
				       (2018,  9, 14, ["Ida","Ronja"])])
	elif year >= 2001:
	    self.place_name_day_names("namnsdagar-2001.txt")
	elif year >= 1993:
	    self.place_name_day_names("namnsdagar-1993.txt")
	elif year >= 1986:
	    self.place_name_day_names("namnsdagar-1986.txt")
	elif year >= 1901:
	    self.place_name_day_names("namnsdagar-1901.txt",
				      [(1905, 11,  4, ["Sverker"]),
				       (1907, 11, 27, ["Astrid"]),
				       (1953,  3, 25 ,["Marie Bebådelsedag"]),
				       (1953,  6, 24 ,["Johannes Döparens dag"]),
				       (1934, 10, 20, ["Sibylla"])])

	# Månfaser
	self.place_moonphases()
Beispiel #3
0
 def set_last_month(self):
     today = jddate.FromToday()
     self.begin = (today.GetMonthStart() - 1).GetMonthStart()
     self.end = self.begin.GetMonthEnd()
Beispiel #4
0
 def set_this_month(self):
     today = jddate.FromToday()
     self.begin = today.GetMonthStart()
     self.end = today.GetMonthEnd()
Beispiel #5
0
 def set_last_week(self):
     today = jddate.FromToday()
     self.begin = today.GetWeekStart() - 7
     self.end = today.GetWeekEnd() - 7
Beispiel #6
0
 def set_yesterday(self):
     self.begin = self.end = jddate.FromToday() - 1
Beispiel #7
0
 def set_today(self):
     self.begin = self.end = jddate.FromToday()