/************************************************************************ * * * Copyright Digital Equipment Corporation 1998. All rights reserved. * * * * Restricted Rights: Use, duplication, or disclosure by the U.S. * * Government is subject to restrictions as set forth in subparagraph * * (c) (1) (ii) of DFARS 252.227-7013, or in FAR 52.227-19, or in FAR * * 52.227-14 Alt. III, as applicable. * * * * This software is proprietary to and embodies the confidential * * technology of Digital Equipment Corporation. Possession, use, or * * copying of this software and media is authorized only pursuant to a * * valid written license from Digital or an authorized sublicensor. * * * ************************************************************************/ /* chap_9_date_time.c */ /* The time function returns the time in seconds; the localtime */ /* function converts the time to hours, minutes, and so on; and */ /* the strftime function uses these values to obtain a string */ /* in the desired format. */ #include #include #define MAX_STRING 80 main() { struct tm *time_structure; time_t time_val; char output_str[MAX_STRING]; time(&time_val); time_structure = localtime(&time_val); /* Print the date */ strftime(output_str, MAX_STRING, "Today is %A, %B %d, %Y", time_structure); printf("%s\n", output_str); /* Print the time using a 12-hour clock format. */ strftime(output_str, MAX_STRING, "The time is %I:%M %p", time_structure); printf("%s\n", output_str); }