Time and Date
You can retrieve strings for any given time or date in a format that is
appropriate for the current locale by using the
GetTimeFormat and
GetDateFormat functions.
For
GetTimeFormat, the time values in the
SYSTEMTIME structure pointed to by
lpTime must be valid. The function checks each of the time values to determine that
it is within the appropriate range of values. If any of the time values are
outside the correct range, the function fails, and sets the last-error to
ERROR_INVALID_PARAMETER.
The function ignores the date portions of the
SYSTEMTIME structure pointed to by
lpTime:
wYear,
wMonth,
wDayOfWeek, and
wDay.
If a time marker exists and the TIME_NOTIMEMARKER flag is not set, the
function localizes the time marker based on the specified locale identifier. Examples
of time markers are "AM" and "PM" for US English, "de." and "du." for Mexican
Spanish.
If TIME_NOMINUTESORSECONDS or TIME_NOSECONDS is specified, the function
removes the separator(s) preceding the minutes and/or seconds element(s).
If TIME_NOTIMEMARKER is specified, the function removes the separator(s)
preceding and following the time marker.
If TIME_FORCE24HOURFORMAT is specified, the function displays any existing
time marker, unless the TIME_NOTIMEMARKER flag is also set.
The function does not include milliseconds as part of the formatted time
string.
To use the LOCALE_NOUSEROVERRIDE flag,
lpFormat must be NULL.
No errors are returned for a bad format string. The function simply forms the
best time string that it can. If more than two hour, minute, second, or time
marker format pictures are passed in, then the function defaults to two. For
example, the only time marker pictures that are valid are L"t" and L"tt" (the 'L'
indicates a Unicode (16-bit characters) string). If L"ttt" is passed in, the
function assumes L"tt".
For
GetDateFormat, the date values in the
SYSTEMTIME structure pointed to by
lpDate must be valid. The function checks each of the date values: year, month, day,
and day of week. If the day of the week is incorrect, the function uses the
correct value, and returns no error. If any of the other date values are outside
the correct range, the function fails, and sets the last-error to
ERROR_INVALID_PARAMETER.
The day name, abbreviated day name, month name, and abbreviated month name are
all localized based on the given locale identifier. The function ignores the
time portions of the
SYSTEMTIME structure pointed to by
lpDate:
wHour,
wMinute,
wSecond, and
wMilliseconds.
The flag DATE_USE_ALT_CALENDAR will always use the format defined as the
default format for that alternate calendar, rather than using any user overrides.
The user overrides will only be used in the event that there is no default
format for the alternate calendar specified.
The DATE_SHORTDATE and DATE_LONGDATE flag options are mutually exclusive. If
neither one is specified and
lpFormat is NULL, then DATE_SHORTDATE is the default.
If the
lpFormat parameter is not NULL, the
dwFlags parameter must be zero. None of the flags make sense when the format string
is specified.
No errors are returned for a bad format string. The function simply forms the
best date string that it can. For example, the only year pictures that are
valid are L"yyyy" and L"yy" (the 'L' indicates a Unicode (16-bit characters)
string). If L"y" is passed in, the function assumes L"yy". If L"yyy" is passed in,
the function assumes L"yyyy". If more than 4 date (L"dddd") or 4 month (L"MMMM")
pictures are passed in, then the function defaults to L"dddd" or L"MMMM".
Any text that should remain in its exact form in the date string should be
enclosed within single quotes in the date format picture. The single quote may
also be used as an escape character to allow the single quote itself to be
displayed in the date string. However, the escape sequence must be enclosed within two
single quotes. For example, to display the date as "May '93", the format
string would be: L"MMMM ''''yy " The first and last single quotes are the
enclosing quotes. The second and third single quotes are the escape sequence to allow
the single quote to be displayed before the century.
- Software for developers
-
Delphi Components
.Net Components
Software for Android Developers
- More information resources
-
MegaDetailed.Net
Unix Manual Pages
Delphi Examples
- Databases for Amazon shops developers
-
Amazon Categories Database
Browse Nodes Database