/* deutsch.langmod */

/* Try not to open too many libraries, in fact it's best to stick to
basic exec stuff ;-) */

#include <stdio.h>
#include <proto/exec.h>

#include <clib/langmod_protos.h>
#include <libraries/langmod.h>

/* The strings.... */

char *months_data[13] = {
	"",
	"Januar",
	"Februar",
	"März",
	"April",
	"Mai",
	"Juni",
	"Juli",
	"August",
	"September",
	"Oktober",	
	"November",
	"Dezember"

};

char *days_data[7] = {
	"Sonntag",
	"Montag",
	"Dienstag",
	"Mittwoch",
	"Donnerstag",
	"Freitag",
	"Samstag"
};

char *engnums[] = {
	"",
	"eins",
	"zwei",
	"drei",
	"vier",
	"fünf",
	"sechs",
	"sieben",
	"acht",
	"noun",
	"zehn",
	"elf",
	"zwölf",
	"dreizehn",
	"vierzehn",
	"viertel", "","","","",
	"zwanzig","","","","",
	"fünfundzwanzig","","","","",
	"halb","","","","",
	"fünfundzwanzig","","","","",
	"zwanzig","","","","",
	"viertel","","","","",
	"zehn","","","",""
	"fünf"
	

};

__asm UBYTE *ECM_GetTimeStr(	register __a0 UBYTE *buffer,
								register __d1 ULONG bufsize,
								register __a1 ULONG *error,
								register __a2 struct EngTime *tm ) {
	char line1[200];
	long temp1;
	BOOL afternoon;
	
	*error=0;
	

	if(tm->hours>12) {
		tm->hours=tm->hours-12;
		afternoon=TRUE;
	} else {
		if(tm->hours==12)
			afternoon=TRUE;
		else
			afternoon=FALSE;
	}

	if(tm->hours==0)  /* Midnight! */
		tm->hours=12;


	strcpy(line1,"Es ist ");
	temp1=(tm->minutes/5)*5;		/* round the minutes */


	if(temp1!=0) 
		strcat(line1,engnums[temp1]);
		

	// Now decide whether it's to the hour, or past the hour
	
	if(temp1 >=30) {
		/* To the hour */
		if(temp1!=30)
			strcat(line1," vor ");
		strcat(line1,engnums[tm->hours+1]);
	} else {
		/* past the hour */
		if(temp1!=0) {
			strcat(line1," nach ");
			strcat(line1,engnums[tm->hours]);
		} else {
			strcat(line1,engnums[tm->hours]);
			strcat(line1," uhr");
			
		}
	}

	if(strlen(line1)>bufsize) {
		*error=ERR_BUFSIZE;
		return(0);
	}

	strcpy(buffer,line1);
	return(buffer);
}

__asm UBYTE *ECM_GetDateStr(	register __a0 UBYTE *buffer,
								register __d1 ULONG bufsize,
								register __a1 ULONG *error,
								register __a2 struct EngTime *tm) {
	char line2[200];
	char tmp[10];
	
	*error=0;

	strcpy(line2,"den ");
	strcat(line2,days_data[tm->wday]);
	strcat(line2,", ");
	sprintf(tmp,"%ld",tm->days);
	strcat(line2,tmp);
	strcat(line2,". ");
	strcat(line2,months_data[tm->months]);
	sprintf(tmp,"%ld",tm->years);
	strcat(line2,", ");
	strcat(line2,tmp);
	

	if(strlen(line2)>bufsize) {
		*error=ERR_BUFSIZE;
		return(0);
	}

	strcpy(buffer,line2);
	return(buffer);
}
