date.c (723B)
1 #include <stdio.h> 2 #include <ctype.h> 3 #include <time.h> 4 #include "status2d.h" 5 6 int 7 main(void) { 8 char buf[BUFSIZ], *p; 9 time_t t = time(NULL); 10 struct tm *tm = localtime(&t); 11 12 strftime(buf, sizeof(buf), "%a", tm); 13 for (p = buf; *p; p++) 14 *p = toupper(*p); 15 if (tm->tm_wday == 0 || tm->tm_wday == 1) /* weekend */ 16 s2d_fg(GREEN); 17 else 18 s2d_fg(GREY); 19 s2d_print("%s", buf); 20 21 strftime(buf, sizeof(buf), "%d/%m", tm); 22 if (tm->tm_mon >= 3 && tm->tm_mon <= 5) 23 s2d_fg(YELLOW); /* spring */ 24 else if (tm->tm_mon >= 6 && tm->tm_mon <= 7) 25 s2d_fg(GREEN); /* summer */ 26 else if (tm->tm_mon >= 8 && tm->tm_mon <= 11) 27 s2d_fg(ORANGE); /* autumn */ 28 else 29 s2d_fg(WHITE); /* winter */ 30 s2d_print("%s", buf); 31 s2d_finish(); 32 }