![]() | Programming Guide | ![]() |
Formats a user-supplied date and time
char *sm_udtime(struct tm *dt_tm_data, char *format);
dt_tm_data- A pointer to the date and time data to format.
dt_tm_datais atmstructure, defined in the standard C header filetime.h.format- Specifies the format to use with an expression that starts with
yorn, followed by any combination of date/time tokens and literal text.yindicates a 12-hour clock;nor any other character indicates a 24-hour clock. This character is required even if the format does not include time tokens. Refer to Table 5-19 for a list of the date/time tokens that you use to build a format expression.
C only
- · A pointer to a string that contains the user date/time in the specified format.
sm_udtimeformats the date and time data indt_tm_dataaccording to the specifiedformat.This function uses a static buffer that it shares with other date and time formatting functions. The buffer is 256 bytes long. Panther does not check for overflow. Consequently, you should process the returned string or copy it to a local variable before making additional function calls.
/* Put the date 135 days from now into the field "maturity" */
#include <smdefs.h>
time_t tim;
struct tm *matdate;
char *ptr;
/* calculate local time in seconds */
tim = time((time_t *)0) + 135L * 24 * 60 * 60;
matdate = localtime(&tim);
ptr = sm_udtime(matdate, " %0f");
sm_n_putfield("maturity", ptr);