/* RFC2822 timestamp and individual day, month and year files */ #include #include #include int main(void) { char rfc2822[200]; FILE *outfpts = NULL; FILE *outfpday = NULL; FILE *outfpmonth = NULL; FILE *outfpyear = NULL; time_t t; struct tm *currenttime; t = time(NULL); currenttime = localtime(&t); strftime(rfc2822, sizeof(rfc2822), "%a, %d %b %Y %H:%M:%S %z", currenttime); outfpts = fopen("${CONFIG_TIMESTAMP_FILE}", "w"); outfpday = fopen("${CONFIG_TIME_DAY_FILE}", "w"); outfpmonth = fopen("${CONFIG_TIME_MONTH_FILE}", "w"); outfpyear = fopen("${CONFIG_TIME_YEAR_FILE}", "w"); fprintf(outfpts, "%s", rfc2822); if (currenttime->tm_mday < 10) fprintf(outfpday, "0"); fprintf(outfpday, "%d", currenttime->tm_mday); if (currenttime->tm_mon < 10) fprintf(outfpmonth, "0"); fprintf(outfpmonth, "%d", currenttime->tm_mon + 1); fprintf(outfpyear, "%d", currenttime->tm_year + 1900); fclose(outfpts); fclose(outfpday); fclose(outfpmonth); fclose(outfpyear); return 0; }