Programming Guide


Formats a user-supplied date and time

char *sm_udtime(struct tm *dt_tm_data, char *format);

A pointer to the date and time data to format. dt_tm_data is a tm structure, defined in the standard C header file time.h.

Specifies the format to use with an expression that starts with y or n, followed by any combination of date/time tokens and literal text. y indicates a 12-hour clock; n or 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-17 for a list of the date/time tokens that you use to build a format expression.


C only



sm_udtime formats the date and time data in dt_tm_data according to the specified format.

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);

See Also