René's Avigo Page: German Hollidays (Feiertage)

German Hollidays
(Feiertage)


This application might only be useful in Germany. But I will stay in English here
nevertheless, since the purpose of this page is to describe the programming aspects of the application. The use
is self explaining anyway. You find the application with source in
this
archive
.


The program does not insert the computed days into the calendar, because I do
not know how to do this. If anybody can do that for me, please help out!


Here is a screen dump of the application.



As you can see, I stick with my main layout of a DeskBox with a menu. In this
deskbox, you will find two objects of type NUMBERSET attached at each other, a button and the output area. The
code to insert the number tickers and the button is simply

	/* A number ticker for the year /	_DATE date;
GetDate(&date);
PNUMBERSET *Year,*Century;
int d=date.year+1901;
century=d/100;
year=d-century*100;
Century=(PNUMBERSET *)CreateNumberSet(
id++,20,30,19,20,1,&century);
LoadBank(&(dsk->insert));
dsk->insert((VOID_PTR)dsk,Century);
Year=(PNUMBERSET *)CreateNumberSet(
id++,Century->right,30,0,99,1,&year);
LoadBank(&(dsk->insert));
dsk->insert((VOID_PTR)dsk,Year);
computeEastern();

/
A button to recompute the year */ PBUTTON *Compute; Compute=(PBUTTON *)CreateButton( id++,Year->right+10,30,Year->right+80, MK_FAR_PTR(“Berechnen”),cmdCompute,bttBasic); LoadBank(&(dsk->insert)); dsk->insert((VOID_PTR)dsk,Compute);

topline=Century->bottom+15;

The year is initialized with the current year. The range of the first ticker is
19,20 and the range of the second 0,…,99. This gives a range from 1900 to 2099. The Easter algorithm works for
other days too, but the Avigo has only this date range and I wanted to use its date computations and output functions
for simplicity. By the way, the Easter algorithm is from a paper of St. Deschauer. Thanks to him!


The output is drawn to the screen in a function draw_output. This is called from
the DESKBOX drawing routine and from the event handler, when the Berechne button is pressed.


The easter algorithm is this.

<font face="Arial, Helvetica">typedef struct _Datum<br />{	int day;<br />	int month;<br />	int year;<br />} Datum;<br /><br />Datum Eastern;<br /><br />void computeEasternGregorian ()<br />{	int s,m,u,M,N,a,b,c,d,e;<br />	s=Eastern.year/100-Eastern.year/400-2;<br />	m=(Eastern.year-100*(Eastern.year/4200))/300-2;<br />	u=s-m;<br />	M=(15+u)%30; N=(6+s)%7;<br />	a=Eastern.year%19; b=Eastern.year%4; c=Eastern.year%7;<br />	d=(M+19*a)%30;<br />	e=(N+2*b+4*c+6*d)%7;<br />	if (d==29)<br />	{	d=28; e=(e+1)%7;<br />	}<br />	if (a&gt;=11 &amp;&amp; d==28)<br />	{	d=27; e=(e+1)%7;<br />	}<br />	Eastern.day=22+d+e;<br />	if (Eastern.day&gt;31)<br />	{	Eastern.month=4;<br />		Eastern.day=Eastern.day-31;<br />	}<br />	else Eastern.month=3;<br />}</font>


Beware not to take the _DATE structure of the Avigo. This has only fields of type
char. Then you have to convert these days to int before using them in int computations. Moreover, the year counts
from 1901 (making 1900 an invalid year). The above algorithm is correct from 1583 on. It is only valid for the
Western Eastern date. There is another algorithm for the Orthodox church.


There is not much more to this program. So you should be able to understand the
program now.





Kommentare

Noch keine Kommentare

Kommentar schreiben


Pavatar/Gravatar/Favatar/MyBlogLog Autoren Bilder werden unterstützt.
Die angegebene E-Mail-Adresse wird nicht dargestellt, sondern nur für eventuelle Benachrichtigungen verwendet.
Textile-Formatierung erlaubt
Letzte Kommentare
Robert Lender zu Problem beim Zugriff auf mein Blog
Di, 02.12.2008 19:50
Robert LenderDanke für die Info. Sorry, ich mer […]


bed zu Problem beim Zugriff auf mein Blog
Di, 02.12.2008 12:16
bedAlso dein http Ping Profil war jed […]


Robert Lender zu iPhone oder nicht - Teil 1
So, 30.11.2008 22:14
Robert LenderDanke für deine Erfahrungen. Brows […]


Jörg zu iPhone oder nicht - Teil 1
So, 30.11.2008 18:15
JörgHallo Robert, ich hab seit Juli […]


Termine
15.12.08 - Web Montag Wien 14 (10 Tage)
31.01.09 - AfricaCamp Vienna 2009 (57 Tage)
13.06.09 - 14.06.09 - BarCamp Vienna (190 Tage)
XML
Creative Commons License
Dieser Inhalt ist unter einer Creative Commons-Lizenz lizenziert.