fork download
  1. #include <stdio.h>
  2. #include <time.h>
  3. #include <string.h>
  4.  
  5. void output_date( int day, int month, int year )
  6. {
  7. char buffer[64] = "";
  8. struct tm e_time;
  9.  
  10. memset( &e_time, 0, sizeof( e_time ) );
  11. e_time.tm_year = year - 1900;
  12. e_time.tm_mon = month - 1;
  13. e_time.tm_mday = day;
  14. e_time.tm_hour = 0;
  15. e_time.tm_min = 0;
  16. e_time.tm_sec = 0;
  17. e_time.tm_isdst = -1;
  18.  
  19.  
  20. //mktime( &e_time );
  21. // Breakdown of the format string (From GCC 4.7x)
  22. // %a - The abbreviated weekday name according to the current locale
  23. // %b - The abbreviated month name according to the current locale.
  24. // %d - The day of the month as a decimal number (range 01 to 31).
  25. // %e - Like %d, the day of the month as a decimal number, but a leading zero is replaced by a space. (SU)
  26. // %H - The hour as a decimal number using a 24-hour clock (range 00 to 23).
  27. // %M - The minute as a decimal number (range 00 to 59).
  28. // %S - The second as a decimal number (range 00 to 60). (The range is up to 60 to allow for occasional leap seconds.)
  29. // %Z - The timezone or name or abbreviation.
  30. // %z - The +hhmm or -hhmm numeric timezone (that is, the hour and minute offset from UTC). (SU)
  31. strftime( buffer, sizeof( buffer ), "%a %b %e %H:%M:%S %Z (%z) %Y", &e_time );
  32.  
  33. printf( "%s\n", buffer );
  34.  
  35. }
  36.  
  37.  
  38. int main(void)
  39. {
  40. output_date( 7, 7, 2013 );
  41. return 0;
  42. }
  43.  
Success #stdin #stdout 0s 2292KB
stdin
Standard input is empty
stdout
Sun Jul  7 00:00:00  () 2013