
#include <time.h>
#include <stdio.h>

int
main (void)
@{
  /* @r{This buffer is big enough that the strftime calls
     below cannot possibly exhaust it.} */
  char buf[256];

  /* @r{Get the current time.} */
  time_t curtime = time (NULL);

  /* @r{Convert it to local time representation.} */
  struct tm *lt = localtime (&curtime);
  if (!lt)
    return 1;

  /* @r{Print the date and time in a simple format
     that is independent of locale.} */
  strftime (buf, sizeof buf, "%Y-%m-%d %H:%M:%S", lt);
  puts (buf);

@group
  /* @r{Print it in a nicer English format.} */
  strftime (buf, sizeof buf, "Today is %A, %B %d.", lt);
  puts (buf);
  strftime (buf, sizeof buf, "The time is %I:%M %p.", lt);
  puts (buf);

  return 0;
@}
@end group
