calendar.c (679B)
1 #include <stdio.h> 2 #include <time.h> 3 #include <string.h> 4 5 #include "../util.h" 6 #include "calendar.h" 7 8 #define ICON " " 9 10 const char days[7][4] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}; 11 const char months[12][4] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", 12 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; 13 14 size_t calendaru(char *str, int sigval) 15 { 16 time_t rawtime; 17 struct tm *ltime; 18 19 time(&rawtime); 20 ltime = localtime(&rawtime); 21 22 return SPRINTF(str, ICON "%s,%02d.%s", days[ltime->tm_wday], 23 ltime->tm_mday, months[ltime->tm_mon]); 24 } 25 26 void calendarc(int button) 27 { 28 TERMCMD("bash", "-c", "cal && read"); 29 }