FormatDateTimeString
int FormatDateTimeString (double dateTime, char formatString[], char outputBuffer[], int outputBufferSize);
Purpose
Formats a given date/time into a string buffer according to descriptions in the formatString parameter.
FormatDateTimeString supports the same absolute date/time format specifiers as the strftime function with the %nf extension.
Example Code
The following code demonstrates how to get the current date and time and then format them according to the specified format string.
#define DATETIME_FORMATSTRING "%I:%M%p %A, %B %d, %Y"
...
double currDateTime;
int bufferLen;
char *dateTimeBuffer = NULL;
GetCurrentDateTime (&currDateTime);
bufferLen = FormatDateTimeString (currDateTime, DATETIME_FORMATSTRING, NULL, 0);
dateTimeBuffer = malloc (bufferLen + 1);
FormatDateTimeString (currDateTime, DATETIME_FORMATSTRING, dateTimeBuffer, bufferLen + 1 );
Parameters
Input | ||
Name | Type | Description |
dateTime | double | The date/time to format. The value is the number of seconds since midnight, January 1, 1900. You can call MakeDateTime to retrieve a specified time in this format, or you can call GetCurrentDateTime to retrieve the current date/time. |
formatString | char [] | The format string that specifies how to convert the date/time for output. The formatString is similar to the format string used in printf. The formatString supports the same absolute date/time format specifiers as the strftime function with the %nf extension. |
outputBufferSize | int | The maximum number of characters, including a terminating NUL character, to be written into outputBuffer. |
Output | ||
Name | Type | Description |
outputBuffer | char [] | The destination buffer for the formatted output. |
Return Value
Name | Type | Description |
status | int | Returns the size of the buffer required to hold the entire formatted string, not including the terminating NUL byte. A negative number indicates that an error occurred. |
Additional Information
Library: User Interface Library
Include file: userint.h
LabWindows/CVI compatibility: LabWindows/CVI 8.0 and later