#include <sys/time.h>
#define w printf
#define q tm_min
#define r tm_hour
char*a[]={"minuit","une","deux","trois","quatre","cinq","six","sept","huit","neuf","dix",
"onze","douze","treize","quatorze","quart","seize","dix-sept","dix-huit","dix-
neuf","vingt","vingt-et-une",0,0,0,0,0,0,0,0,"demi"};h=1;
h=1,s=1,m,e,l,t,p,o,v;
structv;struct tm j;mainj;
main(){struct timeval i;gettimeofday(&i,0);localtime_r(&i.tv_sec,&j);
j.q>30?m=1,++j.r,j.q=60-j.q:j.q==15||j.q==30?e=1:0;j.q>21&&j.q<30?v=1:0;
j.r%12?j.r<12?t=1:j.r-m<17?p=1:(o=1):0;
j.q==15&&m?l=1:0;j.r%12?j.r%12==1?s=0:0:(h=0,s=0);
w("Il est ");j.r==12?w("midi"):w("%s",a[j.r%12]);h?w(" heure"):0;s?w("s"):0;
m?w(" moins"):0;e?w(" et"):0;l?w(" le"):0;
j.q?v?w(" vingt-"):w(" "),w("%s",a[j.q-20*v]):0;
t?w(" du matin"):p?w(" de l'apres-midi"):o?w(" du soir"):0;w(".\n");}
#include <sys/time.h>
#define w printf
#define q tm_min
#define r tm_hour
char*a[]={"minuit","une","deux","trois","quatre","cinq","six","sept","huit","neuf","dix",
"onze","douze","treize","quatorze","quart","seize","dix-sept","dix-huit","dix-
neuf","vingt","vingt-et-une",0,0,0,0,0,0,0,0,"demi"};h=1,s=1,m,e,l,t,p,o,v;
struct tm j;main(){struct timeval i;gettimeofday(&i,0);localtime_r(&i.tv_sec,&j);
j.q>30?m=1,++j.r,j.q=60-j.q:j.q==15||j.q==30?e=1:0;j.q>21&&j.q<30?v=1:0;
j.r%12?j.r<12?t=1:j.r-m<17?p=1:(o=1):0;
j.q==15&&m?l=1:0;j.r%12?j.r%12==1?s=0:0:(h=0,s=0);
w("Il est ");j.r==12?w("midi"):w("%s",a[j.r%12]);h?w(" heure"):0;s?w("s"):0;
m?w(" moins"):0;e?w(" et"):0;l?w(" le"):0;
j.q?v?w(" vingt-"):w(" "),w("%s",a[j.q-20*v]):0;
t?w(" du matin"):p?w(" de l'apres-midi"):o?w(" du soir"):0;w(".\n");}
#include <sys/time.h>
#define w printf
#define q tm_min
#define r tm_hour
char*a[]={"minuit","une","deux","trois","quatre","cinq","six","sept","huit","neuf","dix",
"onze","douze","treize","quatorze","quart","seize","dix-sept","dix-huit","dix-
neuf","vingt","vingt-et-une",0,0,0,0,0,0,0,0,"demi"};
h=1,s=1,m,e,l,t,p,o,v;struct tm j;
main(){struct timeval i;gettimeofday(&i,0);localtime_r(&i.tv_sec,&j);
j.q>30?m=1,++j.r,j.q=60-j.q:j.q==15||j.q==30?e=1:0;j.q>21&&j.q<30?v=1:0;
j.r%12?j.r<12?t=1:j.r-m<17?p=1:(o=1):0;
j.q==15&&m?l=1:0;j.r%12?j.r%12==1?s=0:0:(h=0,s=0);
w("Il est ");j.r==12?w("midi"):w("%s",a[j.r%12]);h?w(" heure"):0;s?w("s"):0;
m?w(" moins"):0;e?w(" et"):0;l?w(" le"):0;
j.q?v?w(" vingt-"):w(" "),w("%s",a[j.q-20*v]):0;
t?w(" du matin"):p?w(" de l'apres-midi"):o?w(" du soir"):0;w(".\n");}
C, 860 835 835794 bytes
Absolutely horrendous, but can probably be made even shorter. Many newlines were added for formatting purposes on this site. The actual source code has newlines after the #includes and #defines, but everything starting from char* to the last w(".\n");} are all in one line. I shortened it by removing the values from 22,...,29 in the string array, instead reusing the strings for 2,...,9 and prepending a "vingt-" when appropriate. (I really hope I didn't introduce a bug!)
#include <sys/time.h>
#define w printf
#define q tm_min
#define r tm_hour
char*a[]={"minuit","une","deux","trois","quatre","cinq","six","sept","huit","neuf","dix","o
nze""onze","douze","treize","quatorze","quart","seize","dix-sept","dix-huit","dix-
neuf","vingt","vingt-et-une","vingt-deux"0,"vingt-trois"0,"vingt-quatre"0,"vingt-
cinq"0,"vingt-six"0,"vingt-sept"0,"vingt-huit"0,"vingt-neuf"0,"demi"};
h=1;h=1,s=1,m,e,l,t,p,o;structo,v;
struct tm j;
mainj;main(){struct timeval i;gettimeofday(&i,0);localtime_r(&i.tv_sec,&j);
j.q>30?m=1,++j.r,j.q=60-j.q:j.q==15||j.q==30?e=1:0;j.q>21&&j.q<30?v=1:0;
j.r%12?j.r<12?t=1:j.r-m<17?p=1:(o=1):0;
j.q==15&&m?l=1:0;j.r%12?j.r%12==1?s=0:0:(h=0,s=0);w;
w("Il est ");
j;j.r==12?w("midi"):w("%s",a[j.r%12]);h?w(" heure"):0;s?w("s"):0;
m?w(" moins"):0;e?w(" et"):0;l?w(" le"):0;j0;
j.q?v?w(" %s"vingt-"):w(" "),w("%s",a[j.q]q-20*v]):0;
t?w(" du matin"):p?w(" de l'apres-midi"):o?w(" du soir"):0;w(".\n");}
#include <sys/time.h>
#define w printf
#define q tm_min
#define r tm_hour
char*a[]={"minuit","une","deux","trois","quatre","cinq","six","sept","huit","neuf","dix","onze","douze","treize","quatorze","quart","seize","dix-sept","dix-huit","dix-neuf","vingt","vingt-et-une","vingt-deux"0,"vingt-trois"0,"vingt-quatre"0,"vingt-cinq"0,"vingt-six"0,"vingt-sept"0,"vingt-huit"0,"vingt-neuf"0,"demi"};h=1,s=1,m,e,l,t,p,o;structo,v;struct tm j;main(){struct timeval i;gettimeofday(&i,0);localtime_r(&i.tv_sec,&j);j.q>30?m=1,++j.r,j.q=60-j.q:j.q==15||j.q==30?e=1:0;j.q>21&&j.q<30?v=1:0;j.r%12?j.r<12?t=1:j.r-m<17?p=1:(o=1):0;j.q==15&&m?l=1:0;j.r%12?j.r%12==1?s=0:0:(h=0,s=0);w("Il est ");j.r==12?w("midi"):w("%s",a[j.r%12]);h?w(" heure"):0;s?w("s"):0;m?w(" moins"):0;e?w(" et"):0;l?w(" le"):0;j.q?v?w(" %s"vingt-"):w(" "),w("%s",a[j.q]q-20*v]):0;t?w(" du matin"):p?w(" de l'apres-midi"):o?w(" du soir"):0;w(".\n");}
Ungolfed version, with no "space optimizations" (also pretty ugly):
C, 860 835 bytes
Absolutely horrendous, but can probably be made even shorter. Many newlines were added for formatting purposes on this site. The actual source code has newlines after the #includes and #defines, but everything starting from char* to the last w(".\n");} are all in one line.
#include <sys/time.h>
#define w printf
#define q tm_min
#define r tm_hour
char*a[]={"minuit","une","deux","trois","quatre","cinq","six","sept","huit","neuf","dix","o
nze","douze","treize","quatorze","quart","seize","dix-sept","dix-huit","dix-
neuf","vingt","vingt-et-une","vingt-deux","vingt-trois","vingt-quatre","vingt-
cinq","vingt-six","vingt-sept","vingt-huit","vingt-neuf","demi"};
h=1,s=1,m,e,l,t,p,o;struct tm j;
main(){struct timeval i;gettimeofday(&i,0);localtime_r(&i.tv_sec,&j);
j.q>30?m=1,++j.r,j.q=60-j.q:j.q==15||j.q==30?e=1:0;
j.r%12?j.r<12?t=1:j.r-m<17?p=1:(o=1):0;
j.q==15&&m?l=1:0;j.r%12?j.r%12==1?s=0:0:(h=0,s=0);w("Il est ");
j.r==12?w("midi"):w("%s",a[j.r%12]);h?w(" heure"):0;s?w("s"):0;
m?w(" moins"):0;e?w(" et"):0;l?w(" le"):0;j.q?w(" %s",a[j.q]):0;
t?w(" du matin"):p?w(" de l'apres-midi"):o?w(" du soir"):0;w(".\n");}
#include <sys/time.h>
#define w printf
#define q tm_min
#define r tm_hour
char*a[]={"minuit","une","deux","trois","quatre","cinq","six","sept","huit","neuf","dix","onze","douze","treize","quatorze","quart","seize","dix-sept","dix-huit","dix-neuf","vingt","vingt-et-une","vingt-deux","vingt-trois","vingt-quatre","vingt-cinq","vingt-six","vingt-sept","vingt-huit","vingt-neuf","demi"};h=1,s=1,m,e,l,t,p,o;struct tm j;main(){struct timeval i;gettimeofday(&i,0);localtime_r(&i.tv_sec,&j);j.q>30?m=1,++j.r,j.q=60-j.q:j.q==15||j.q==30?e=1:0;j.r%12?j.r<12?t=1:j.r-m<17?p=1:(o=1):0;j.q==15&&m?l=1:0;j.r%12?j.r%12==1?s=0:0:(h=0,s=0);w("Il est ");j.r==12?w("midi"):w("%s",a[j.r%12]);h?w(" heure"):0;s?w("s"):0;m?w(" moins"):0;e?w(" et"):0;l?w(" le"):0;j.q?w(" %s",a[j.q]):0;t?w(" du matin"):p?w(" de l'apres-midi"):o?w(" du soir"):0;w(".\n");}
Ungolfed version (also pretty ugly):
C, 860 835 794 bytes
Absolutely horrendous, but can probably be made even shorter. Many newlines were added for formatting purposes on this site. The actual source code has newlines after the #includes and #defines, but everything starting from char* to the last w(".\n");} are all in one line. I shortened it by removing the values from 22,...,29 in the string array, instead reusing the strings for 2,...,9 and prepending a "vingt-" when appropriate. (I really hope I didn't introduce a bug!)
#include <sys/time.h>
#define w printf
#define q tm_min
#define r tm_hour
char*a[]={"minuit","une","deux","trois","quatre","cinq","six","sept","huit","neuf","dix",
"onze","douze","treize","quatorze","quart","seize","dix-sept","dix-huit","dix-
neuf","vingt","vingt-et-une",0,0,0,0,0,0,0,0,"demi"};h=1,s=1,m,e,l,t,p,o,v;
struct tm j;main(){struct timeval i;gettimeofday(&i,0);localtime_r(&i.tv_sec,&j);
j.q>30?m=1,++j.r,j.q=60-j.q:j.q==15||j.q==30?e=1:0;j.q>21&&j.q<30?v=1:0;
j.r%12?j.r<12?t=1:j.r-m<17?p=1:(o=1):0;
j.q==15&&m?l=1:0;j.r%12?j.r%12==1?s=0:0:(h=0,s=0);
w("Il est ");j.r==12?w("midi"):w("%s",a[j.r%12]);h?w(" heure"):0;s?w("s"):0;
m?w(" moins"):0;e?w(" et"):0;l?w(" le"):0;
j.q?v?w(" vingt-"):w(" "),w("%s",a[j.q-20*v]):0;
t?w(" du matin"):p?w(" de l'apres-midi"):o?w(" du soir"):0;w(".\n");}
#include <sys/time.h>
#define w printf
#define q tm_min
#define r tm_hour
char*a[]={"minuit","une","deux","trois","quatre","cinq","six","sept","huit","neuf","dix","onze","douze","treize","quatorze","quart","seize","dix-sept","dix-huit","dix-neuf","vingt","vingt-et-une",0,0,0,0,0,0,0,0,"demi"};h=1,s=1,m,e,l,t,p,o,v;struct tm j;main(){struct timeval i;gettimeofday(&i,0);localtime_r(&i.tv_sec,&j);j.q>30?m=1,++j.r,j.q=60-j.q:j.q==15||j.q==30?e=1:0;j.q>21&&j.q<30?v=1:0;j.r%12?j.r<12?t=1:j.r-m<17?p=1:(o=1):0;j.q==15&&m?l=1:0;j.r%12?j.r%12==1?s=0:0:(h=0,s=0);w("Il est ");j.r==12?w("midi"):w("%s",a[j.r%12]);h?w(" heure"):0;s?w("s"):0;m?w(" moins"):0;e?w(" et"):0;l?w(" le"):0;j.q?v?w(" vingt-"):w(" "),w("%s",a[j.q-20*v]):0;t?w(" du matin"):p?w(" de l'apres-midi"):o?w(" du soir"):0;w(".\n");}
Ungolfed version, with no "space optimizations" (also pretty ugly):
C, 860860 835 bytes
#include <time.h>
#include <sys/time.h>
#define w printf
#define q tm_min
#define r tm_hour
#define z struct
char*a[]={"minuit","une","deux","trois","quatre","cinq","six","sept","huit","neuf","dix","o
nze","douze","treize","quatorze","quart","seize","dix-sept","dix-huit","dix-
neuf","vingt","vingt-et-une","vingt-deux","vingt-trois","vingt-quatre","vingt-
cinq","vingt-six","vingt-sept","vingt-huit","vingt-neuf","demi"};
h=1,s=1,m,e,l,t,p,o;zo;struct tm j;
main(){zstruct timeval i;gettimeofday(&i,0);localtime_r(&i.tv_sec,&j);
j.q>30?m=1,++j.r,j.q=60-j.q:j.q==15||j.q==30?e=1:0;
j.r%12?j.r<12?t=1:j.r-m<17?p=1:(o=1):0;
j.q==15&&m?l=1:0;j.r%12?j.r%12==1?s=0:0:(h=0,s=0);w("Il est ");
j.r==12?w("midi"):w("%s",a[j.r%12]);h?w(" heure"):0;s?w("s"):0;
m?w(" moins"):0;e?w(" et"):0;l?w(" le"):0;j.q?w(" %s",a[j.q]):0;
t?w(" du matin"):p?w(" de l'apres-midi"):o?w(" du soir"):0;w(".\n");}
#include <time.h>
#include <sys/time.h>
#define w printf
#define q tm_min
#define r tm_hour
#define z struct
char*a[]={"minuit","une","deux","trois","quatre","cinq","six","sept","huit","neuf","dix","onze","douze","treize","quatorze","quart","seize","dix-sept","dix-huit","dix-neuf","vingt","vingt-et-une","vingt-deux","vingt-trois","vingt-quatre","vingt-cinq","vingt-six","vingt-sept","vingt-huit","vingt-neuf","demi"};h=1,s=1,m,e,l,t,p,o;zo;struct tm j;main(){zstruct timeval i;gettimeofday(&i,0);localtime_r(&i.tv_sec,&j);j.q>30?m=1,++j.r,j.q=60-j.q:j.q==15||j.q==30?e=1:0;j.r%12?j.r<12?t=1:j.r-m<17?p=1:(o=1):0;j.q==15&&m?l=1:0;j.r%12?j.r%12==1?s=0:0:(h=0,s=0);w("Il est ");j.r==12?w("midi"):w("%s",a[j.r%12]);h?w(" heure"):0;s?w("s"):0;m?w(" moins"):0;e?w(" et"):0;l?w(" le"):0;j.q?w(" %s",a[j.q]):0;t?w(" du matin"):p?w(" de l'apres-midi"):o?w(" du soir"):0;w(".\n");}
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <sys/time.h>
int main(int argc, char *argv[])
{
struct timeval tv;
struct tm local_time;
char tmbuf[64], timebuf[64];
char *nums[] = {"minuit", "une", "deux", "trois", "quatre", "cinq", "six", "sept", "huit", "neuf", "dix", "onze", "douze", "treize", "quatorze", "quart", "seize", "dix-sept", "dix-huit", "dix-neuf", "vingt", "vingt-et-une", "vingt-deux", "vingt-trois", "vingt-quatre", "vingt-cinq", "vingt-six", "vingt-sept", "vingt-huit", "vingt-neuf", "demi"};
int heure = 1;
int s = 1;
int moins = 0;
int et = 0;
int le = 0;
int matin = 0, aprem = 0, soir = 0;
memset(&local_time, 0, sizeof local_time);
gettimeofday(&tv, NULL);
localtime_r(&tv.tv_sec, &local_time);
#if 0
local_time.tm_min = atoi(argv[1]);
local_time.tm_hour = atoi(argv[2]);
#endif
if (local_time.tm_min > 30) {
moins = 1;
local_time.tm_hour += 1;
local_time.tm_min = 60 - local_time.tm_min;
} else if (local_time.tm_min == 15 || local_time.tm_min == 30) {
et = 1;
}
if (local_time.tm_hour % 12) {
if (local_time.tm_hour < 12)
matin = 1;
else if (local_time.tm_hour < 17)
aprem = 1;
else if (local_time.tm_hour == 17 && moins)
aprem = 1;
else
soir = 1;
}
if (local_time.tm_min == 15 && moins)
le = 1;
if (local_time.tm_hour % 12 == 0) {
heure = 0;
s = 0;
} else if (local_time.tm_hour % 12 == 1) {
s = 0;
}
printf("Il est ");
if (local_time.tm_hour == 12)
printf("midi");
else
printf("%s", nums[local_time.tm_hour % 12]);
if (heure)
printf(" heure");
if (s)
printf("s");
if (moins)
printf(" moins");
if (et)
printf(" et");
if (le)
printf(" le");
if (local_time.tm_min)
printf(" %s", nums[local_time.tm_min]);
if (matin)
printf(" du matin");
else if (aprem)
printf(" de l'apres-midi");
else if (soir)
printf(" du soir");
printf(".\n");
return 0;
}
C, 860 bytes
#include <time.h>
#include <sys/time.h>
#define w printf
#define q tm_min
#define r tm_hour
#define z struct
char*a[]={"minuit","une","deux","trois","quatre","cinq","six","sept","huit","neuf","dix","o
nze","douze","treize","quatorze","quart","seize","dix-sept","dix-huit","dix-
neuf","vingt","vingt-et-une","vingt-deux","vingt-trois","vingt-quatre","vingt-
cinq","vingt-six","vingt-sept","vingt-huit","vingt-neuf","demi"};
h=1,s=1,m,e,l,t,p,o;z tm j;
main(){z timeval i;gettimeofday(&i,0);localtime_r(&i.tv_sec,&j);
j.q>30?m=1,++j.r,j.q=60-j.q:j.q==15||j.q==30?e=1:0;
j.r%12?j.r<12?t=1:j.r-m<17?p=1:(o=1):0;
j.q==15&&m?l=1:0;j.r%12?j.r%12==1?s=0:0:(h=0,s=0);w("Il est ");
j.r==12?w("midi"):w("%s",a[j.r%12]);h?w(" heure"):0;s?w("s"):0;
m?w(" moins"):0;e?w(" et"):0;l?w(" le"):0;j.q?w(" %s",a[j.q]):0;
t?w(" du matin"):p?w(" de l'apres-midi"):o?w(" du soir"):0;w(".\n");}
#include <time.h>
#include <sys/time.h>
#define w printf
#define q tm_min
#define r tm_hour
#define z struct
char*a[]={"minuit","une","deux","trois","quatre","cinq","six","sept","huit","neuf","dix","onze","douze","treize","quatorze","quart","seize","dix-sept","dix-huit","dix-neuf","vingt","vingt-et-une","vingt-deux","vingt-trois","vingt-quatre","vingt-cinq","vingt-six","vingt-sept","vingt-huit","vingt-neuf","demi"};h=1,s=1,m,e,l,t,p,o;z tm j;main(){z timeval i;gettimeofday(&i,0);localtime_r(&i.tv_sec,&j);j.q>30?m=1,++j.r,j.q=60-j.q:j.q==15||j.q==30?e=1:0;j.r%12?j.r<12?t=1:j.r-m<17?p=1:(o=1):0;j.q==15&&m?l=1:0;j.r%12?j.r%12==1?s=0:0:(h=0,s=0);w("Il est ");j.r==12?w("midi"):w("%s",a[j.r%12]);h?w(" heure"):0;s?w("s"):0;m?w(" moins"):0;e?w(" et"):0;l?w(" le"):0;j.q?w(" %s",a[j.q]):0;t?w(" du matin"):p?w(" de l'apres-midi"):o?w(" du soir"):0;w(".\n");}
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <sys/time.h>
int main(int argc, char *argv[])
{
struct timeval tv;
struct tm local_time;
char tmbuf[64], timebuf[64];
char *nums[] = {"minuit", "une", "deux", "trois", "quatre", "cinq", "six", "sept", "huit", "neuf", "dix", "onze", "douze", "treize", "quatorze", "quart", "seize", "dix-sept", "dix-huit", "dix-neuf", "vingt", "vingt-et-une", "vingt-deux", "vingt-trois", "vingt-quatre", "vingt-cinq", "vingt-six", "vingt-sept", "vingt-huit", "vingt-neuf", "demi"};
int heure = 1;
int s = 1;
int moins = 0;
int et = 0;
int le = 0;
int matin = 0, aprem = 0, soir = 0;
memset(&local_time, 0, sizeof local_time);
gettimeofday(&tv, NULL);
localtime_r(&tv.tv_sec, &local_time);
#if 0
local_time.tm_min = atoi(argv[1]);
local_time.tm_hour = atoi(argv[2]);
#endif
if (local_time.tm_min > 30) {
moins = 1;
local_time.tm_hour += 1;
local_time.tm_min = 60 - local_time.tm_min;
} else if (local_time.tm_min == 15 || local_time.tm_min == 30) {
et = 1;
}
if (local_time.tm_hour % 12) {
if (local_time.tm_hour < 12)
matin = 1;
else if (local_time.tm_hour < 17)
aprem = 1;
else if (local_time.tm_hour == 17 && moins)
aprem = 1;
else
soir = 1;
}
if (local_time.tm_min == 15 && moins)
le = 1;
if (local_time.tm_hour % 12 == 0) {
heure = 0;
s = 0;
} else if (local_time.tm_hour % 12 == 1) {
s = 0;
}
printf("Il est ");
if (local_time.tm_hour == 12)
printf("midi");
else
printf("%s", nums[local_time.tm_hour % 12]);
if (heure)
printf(" heure");
if (s)
printf("s");
if (moins)
printf(" moins");
if (et)
printf(" et");
if (le)
printf(" le");
if (local_time.tm_min)
printf(" %s", nums[local_time.tm_min]);
if (matin)
printf(" du matin");
else if (aprem)
printf(" de l'apres-midi");
else if (soir)
printf(" du soir");
printf(".\n");
return 0;
}
C, 860 835 bytes
#include <sys/time.h>
#define w printf
#define q tm_min
#define r tm_hour
char*a[]={"minuit","une","deux","trois","quatre","cinq","six","sept","huit","neuf","dix","o
nze","douze","treize","quatorze","quart","seize","dix-sept","dix-huit","dix-
neuf","vingt","vingt-et-une","vingt-deux","vingt-trois","vingt-quatre","vingt-
cinq","vingt-six","vingt-sept","vingt-huit","vingt-neuf","demi"};
h=1,s=1,m,e,l,t,p,o;struct tm j;
main(){struct timeval i;gettimeofday(&i,0);localtime_r(&i.tv_sec,&j);
j.q>30?m=1,++j.r,j.q=60-j.q:j.q==15||j.q==30?e=1:0;
j.r%12?j.r<12?t=1:j.r-m<17?p=1:(o=1):0;
j.q==15&&m?l=1:0;j.r%12?j.r%12==1?s=0:0:(h=0,s=0);w("Il est ");
j.r==12?w("midi"):w("%s",a[j.r%12]);h?w(" heure"):0;s?w("s"):0;
m?w(" moins"):0;e?w(" et"):0;l?w(" le"):0;j.q?w(" %s",a[j.q]):0;
t?w(" du matin"):p?w(" de l'apres-midi"):o?w(" du soir"):0;w(".\n");}
#include <sys/time.h>
#define w printf
#define q tm_min
#define r tm_hour
char*a[]={"minuit","une","deux","trois","quatre","cinq","six","sept","huit","neuf","dix","onze","douze","treize","quatorze","quart","seize","dix-sept","dix-huit","dix-neuf","vingt","vingt-et-une","vingt-deux","vingt-trois","vingt-quatre","vingt-cinq","vingt-six","vingt-sept","vingt-huit","vingt-neuf","demi"};h=1,s=1,m,e,l,t,p,o;struct tm j;main(){struct timeval i;gettimeofday(&i,0);localtime_r(&i.tv_sec,&j);j.q>30?m=1,++j.r,j.q=60-j.q:j.q==15||j.q==30?e=1:0;j.r%12?j.r<12?t=1:j.r-m<17?p=1:(o=1):0;j.q==15&&m?l=1:0;j.r%12?j.r%12==1?s=0:0:(h=0,s=0);w("Il est ");j.r==12?w("midi"):w("%s",a[j.r%12]);h?w(" heure"):0;s?w("s"):0;m?w(" moins"):0;e?w(" et"):0;l?w(" le"):0;j.q?w(" %s",a[j.q]):0;t?w(" du matin"):p?w(" de l'apres-midi"):o?w(" du soir"):0;w(".\n");}
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <sys/time.h>
int main(int argc, char *argv[])
{
struct timeval tv;
struct tm local_time;
char *nums[] = {"minuit", "une", "deux", "trois", "quatre", "cinq", "six", "sept", "huit", "neuf", "dix", "onze", "douze", "treize", "quatorze", "quart", "seize", "dix-sept", "dix-huit", "dix-neuf", "vingt", "vingt-et-une", "vingt-deux", "vingt-trois", "vingt-quatre", "vingt-cinq", "vingt-six", "vingt-sept", "vingt-huit", "vingt-neuf", "demi"};
int heure = 1;
int s = 1;
int moins = 0;
int et = 0;
int le = 0;
int matin = 0, aprem = 0, soir = 0;
memset(&local_time, 0, sizeof local_time);
gettimeofday(&tv, NULL);
localtime_r(&tv.tv_sec, &local_time);
#if 0
local_time.tm_min = atoi(argv[1]);
local_time.tm_hour = atoi(argv[2]);
#endif
if (local_time.tm_min > 30) {
moins = 1;
local_time.tm_hour += 1;
local_time.tm_min = 60 - local_time.tm_min;
} else if (local_time.tm_min == 15 || local_time.tm_min == 30) {
et = 1;
}
if (local_time.tm_hour % 12) {
if (local_time.tm_hour < 12)
matin = 1;
else if (local_time.tm_hour < 17)
aprem = 1;
else if (local_time.tm_hour == 17 && moins)
aprem = 1;
else
soir = 1;
}
if (local_time.tm_min == 15 && moins)
le = 1;
if (local_time.tm_hour % 12 == 0) {
heure = 0;
s = 0;
} else if (local_time.tm_hour % 12 == 1) {
s = 0;
}
printf("Il est ");
if (local_time.tm_hour == 12)
printf("midi");
else
printf("%s", nums[local_time.tm_hour % 12]);
if (heure)
printf(" heure");
if (s)
printf("s");
if (moins)
printf(" moins");
if (et)
printf(" et");
if (le)
printf(" le");
if (local_time.tm_min)
printf(" %s", nums[local_time.tm_min]);
if (matin)
printf(" du matin");
else if (aprem)
printf(" de l'apres-midi");
else if (soir)
printf(" du soir");
printf(".\n");
return 0;
}