Back to index

glibc  2.9
strftim.c
Go to the documentation of this file.
00001 #include <time.h>
00002 #include <stdio.h>
00003 
00004 #define SIZE 256
00005 
00006 int
00007 main (void)
00008 {
00009   char buffer[SIZE];
00010   time_t curtime;
00011   struct tm *loctime;
00012 
00013   /* Get the current time. */
00014   curtime = time (NULL);
00015 
00016   /* Convert it to local time representation. */
00017   loctime = localtime (&curtime);
00018 
00019   /* Print out the date and time in the standard format. */
00020   fputs (asctime (loctime), stdout);
00021 
00022 /*@group*/
00023   /* Print it out in a nice format. */
00024   strftime (buffer, SIZE, "Today is %A, %B %d.\n", loctime);
00025   fputs (buffer, stdout);
00026   strftime (buffer, SIZE, "The time is %I:%M %p.\n", loctime);
00027   fputs (buffer, stdout);
00028 
00029   return 0;
00030 }
00031 /*@end group*/