Introduce TinyHttp server
[lcapit-junk-code.git] / julian-day.c
blobb5768a4d5508ffc4eee91d27eb4d2c14fba83b61
1 /* Show the day number (julian calendar) */
3 #include <stdio.h>
4 #include <string.h>
5 #include <stdlib.h>
6 #include <time.h>
8 int main(void)
10 char datastr[16];
11 struct tm *tm;
12 struct tm date;
13 time_t timep;
15 timep = time(NULL);
16 tm = localtime(&timep);
17 if (!tm) {
18 perror("localtime()");
19 exit(1);
22 memset(&date, 0, sizeof(date));
23 date.tm_yday = tm->tm_yday;
24 date.tm_year = tm->tm_year;
26 datastr[0] = '\0';
27 strftime(datastr, sizeof(datastr), "%j/%Y", &date);
28 printf("%s\n", datastr);
29 return 0;