Determine whether the specified language uses 12-hour or 24-hour time.
DBBOOL db12hour(dbproc, language) DBPROCESS *dbproc; char *language;
A pointer to the DBPROCESS structure that provides the connection for a particular front-end/server process. It contains all the information that DB-Library uses to manage communications and data between the front end and server.
The name of the language of interest.
“TRUE” if language uses 12-hour time, “FALSE” otherwise.
db12hour returns “TRUE” if language uses 12-hour time, and “FALSE” if it uses 24-hour time.
If language is NULL, dbproc’s current language is signified. If both language and dbproc are NULL, then DB-Library’s default language (for any future calls to dbopen) is signified.
db12hour is useful when retrieving and manipulating DBDATETIME values using dbsqlexec. When converting DBDATETIME values to character strings, dbconvert and dbbind always return the month component of the DBDATETIME value in the local language, but use the U.S. English date and time order (month-day-year, 12-hour time). db12hour’s return value informs the application that some further manipulation is necessary if 24-hour rather than 12-hour time is desired.
The following code fragment illustrates the use of db12hour:
DBBOOL time_format;
DBCHAR s_date[40];
/*
** Find out whether 12-hour or 24-hour time is
** used.
*/
time_format = db12hour(dbproc, "FRANCAIS");
/* Put a command into a command buffer */
dbcmd(dbproc, "select start_date from info_table");
/* Send the command to the Adaptive Server Enterprise */
dbsqlexec(dbproc);
/* Process the command results */
dbresults(dbproc);
/*
** Bind column data (start_date) to the program
** variable (s_date)
*/
dbbind(dbproc, 1, NTBSTRINGBIND, 0, s_date);
while (dbnextrow(dbproc) != NO_MORE_ROWS)
{
/*
** If we want 24-hour time, re-format
** s_date accordingly.
*/
if (time_format == TRUE)
format_24(s_date);
printf("Next start date: %s\n", s_date);
}