Programming Guide |
Gets the formatted system date and time
char *sm_sdtime(char *format);
format
- Specifies the format to use with an expression that starts with
y
orn
, 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. The table in Description shows the date/time tokens that you use to build a format expression.
- · A pointer to a string that contains the current date/time in the specified format.
sm_sdtime
gets the current date and/or time from the operating system and returns it in theformat
-specified format.The following table lists the tokens you use to build a format expression. All tokens are prefixed by the percent sign (%) and are case-sensitive.
At runtime, Panther strips off the first character of
format
. If the character isy
, it uses a 12-hour clock; otherwise, it uses the 24-hour clock. Next, it examines the rest offormat
, replacing any tokens with the appropriate values. All non-token characters are treated as literal values.The message file contains the text for day and month names, AM and PM, and the tokens for the default formats. You can modify these. Refer to "Date/Time Defaults" in Application Development Guide for details.
sm_sdtime
uses a 256-byte static buffer that it shares with other date and time formatting functions. Because Panther does not check for overflow, process the returned string or copy it to a local variable immediately.
#include <smdefs.h>
/* Put current date MONTH-DAY-YEAR in the field "time". */
char *format;
format = "n%m-%0d-%2y";
sm_n_putfield("time", sm_sdtime(format));