/* francais.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 "langmod_protos.h"
#include "langmod.h"

/* The strings.... */

char *months_data[] = {
   "",
   "Janvier",
   "Février",
   "Mars",
   "Avril",
   "Mai",
   "Juin",
   "Juillet",
   "Août",
   "Septembre",
   "Octobre",
   "Novembre",
   "Décembre"
};

char *days_data[] = {
   "Dimanche",
   "Lundi",
   "Mardi",
   "Mercredi",
   "Jeudi",
   "Vendredi",
   "Samedi"
};

char *engnums[] = {
	"",
	"un",
	"deux",
	"trois",
	"quatre",
	"cinq",
	"six",
	"sept",
	"huit",
	"neuf", 
	"dix",
	"onze", 
	"douze",
	"","",
	"et quart",
	"","","","",
	"vingt",
	"","","","",
	"vingt-cinq",
	"","","","",
	"et demie",
	"","","","",
	"vingt-cinq",
	"","","","",
	"vingt",
	"","","","",
	"quart", 
	"","","","",
	"dix",
	"","","","",
	"cinq",
};

__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;

	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;
	
	*error=0;
	
	strcpy(line1,"Il est");
	temp1=(tm->minutes/5)*5;
	if((tm->minutes-temp1)>2)
		strcat(line1," bientôt");

	strcat(line1," ");
	if(tm->minutes<=32) 
		strcat(line1,engnums[tm->hours]);
	else {
		if(tm->hours==12) 
			strcat(line1,engnums[1]); 
		else 
			strcat(line1,engnums[tm->hours+1]);
	}

	strcat(line1," heures");
	if(tm->minutes>2 & tm->minutes<58) {
		strcat(line1," ");
		if(tm->minutes>32)
			strcat(line1,"moins ");
		if((tm->minutes-temp1)<=2) 
			strcat(line1,engnums[(tm->minutes/5)*5]); 
		else 
			strcat(line1,engnums[((tm->minutes/5)+1)*5]);
	}

	if((tm->minutes-temp1)<=2)
		strcat(line1," passées");
		
	
	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,days_data[tm->wday]);
	sprintf(tmp," %ld ",tm->days);
	strcat(line2,tmp);
	strcat(line2,months_data[tm->months]);
	sprintf(tmp,", %ld",tm->years);
	strcat(line2,tmp);
	
	if(strlen(line2) > bufsize) {
		*error=ERR_BUFSIZE;
		return(0);
	}

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

}
