网站首页  词典首页

请输入您要查询的函数:

 

术语 gettimeformat
释义 GetTimeFormat
语法:
int GetTimeFormat(
__in LCID Locale,
__in DWORD dwFlags,
__in const SYSTEMTIME *lpTime,
__in LPCTSTR lpFormat,
__out LPTSTR lpTimeStr,
__in int cchTime
);
GetTimeFormat功能
格式的时间,作为由标识符指定的区域设置的时间字符串。函数格式之一指定的时间和本地系统时间。
注意:对于互操作性的原因,应用程序应更喜欢GetTimeFormatEx功能GetTimeFormat,因为微软是对的,而不是新的区域设置的区域设置标识符地区名称的使用迁移。任何将只运行在Windows Vista和以后应使用GetTimeFormatEx申请。
参数
区域设置 [in]
区域设置标识符指定的语言环境。您可以使用MAKELCID宏创建一个区域设置标识符或使用下列预定义的值之一。
LOCALE_CUSTOM_DEFAULT
LOCALE_CUSTOM_UI_DEFAULT
LOCALE_CUSTOM_UNSPECIFIED
LOCALE_INVARIANT
LOCALE_SYSTEM_DEFAULT
LOCALE_USER_DEFAULT
dwFlags [in]
旗指定的时间格式选项。应用程序可以指定下列值和LOCALE_USE_CP_ACP或LOCALE_NOUSEROVERRIDE组合。
警示LOCALE_NOUSEROVERRIDE强烈建议不要使用,因为它禁用用户的喜好。
ValueMeaning
TIME_NOMINUTESORSECONDSDo不使用分钟或秒。
TIME_NOSECONDSDo不使用秒。
TIME_NOTIMEMARKERDo不要使用时间标志。
TIME_FORCE24HOURFORMATAlways使用24小时的时间格式。
lpTime [in]
可选。指针一个SYSTEMTIME结构,它包含的信息以格式。应用程序可以将此参数设置为NULL,如果该函数使用当前本地系统时间。
lpFormat [in]
可选。指针图片的格式使用格式化时间字符串。如果应用程序设置此参数为NULL,则函数的格式字符串按照指定的地点时间格式。如果应用程序不设置参数为NULL,则函数只使用不为字符串中指定格式的图片资料的语言环境,例如,区域设置特定的时间标记。有关图片格式字符串信息,请参见备注部分。
lpTimeStr [out]
可选。缓冲区指针在本函数检索格式化的时间字符串。
cchTime [in]
大小,在TCHAR价值,时间字符串缓冲区所指出的lpTimeStr。另外,应用程序可以设置为0参数。在这种情况下,该函数返回的时间字符串缓冲区所需的大小,以及不使用lpTimeStr参数。
返回值
返回TCHAR数字值检索的缓冲区lpTimeStr表示。如果cchTime参数设置为0,则函数返回须持有格式化的时间字符串缓冲区,其中包括终止空字符的大小。
这个函数返回0,如果没有成功。为了获得更多错误信息,应用程序可以调用GetLastError函数,可以返回以下错误代码之一:
ERROR_INSUFFICIENT_BUFFER。阿提供的缓冲区大小不够大,或者被错误地设置为NULL。
ERROR_INVALID_FLAGS。旗帜提供的值不是有效的。
ERROR_INVALID_PARAMETER。该参数值的任何无效。
ERROR_OUTOFMEMORY。没有足够的存储是可用于完成此操作。
备注
如果时间标记存在,TIME_NOTIMEMARKER标志未设置,职能本地化的时间标记在指定的区域设置标识符。时间标记的例子是“AM”和“下午”英语(美国)。
在结构方面所显示的时间值lpTime必须是有效的。该函数的时间检查每个值以确定它的价值在适当范围内。如果时间值以外的任何正确的范围是,该功能失败,并设置最后一个错误的ERROR_INVALID_PARAMETER。
该函数忽略了SYSTEMTIME结构成员的日期。这些措施包括:wYear,wMonth,wDayOfWeek,和星期标志。
如果TIME_NOMINUTESORSECONDS或TIME_NOSECONDS指定,函数删除分隔符分钟前和/或秒的成员。
如果TIME_NOTIMEMARKER指定,函数删除分隔符之前和之后的时间标记。
如果TIME_FORCE24HOURFORMAT指定,任何现有的函数显示时间标记,除非TIME_NOTIMEMARKER标志也设置。
该函数不包括作为格式化字符串的一部分毫秒的时间。
该函数返回一个坏的格式字符串没有错误,而是形成了最佳的时间字符串。如果超过两个小时,分,秒,或时间标记格式的图片传递,函数默认为2。例如,只有时间标记的照片,有有效的是“T”和“特”。如果“当前位置:主页”的通过,该函数假定为“特”。
要获取不进行任何实际的格式化时间格式,应用程序应该使用GetLocaleInfo函数,指定LOCALE_STIMEFORMAT。
应用程序可以使用下列内容兴建格式图片字符串。如果用空格分隔格式字符串中的元素,这些空间出现在输出字符串相同的位置。该字母必须大写或小写所示,例如,“党卫军”,而不是“SS”的。格式字符串中单引号括起来的字符出现在相同的位置和输出字符串不变。
PictureMeaning
没有单数的小时前导零hHours,12小时制
与领先的单数的小时零hhHours,12小时制
没有单数的小时前导零HHours,24小时制
与领先的单数的小时零HHHours,24小时制
mMinutes没有为个位数分钟前导零
mmMinutes与领先的单数字分钟零
sSeconds没有为个位数领先零秒
ssSeconds与领先的单数字秒零
音字符字符串的时间标记,如A或P
ttMulti字符的字符串的时间标记,如AM或PM,
例如,要得到时间字符串
“下午11点29分40秒”
应用程序应该使用图片字符串
“螺杆菌':'毫米':'?特”
这个功能可以自定义区域设置检索数据。数据不能保证从同一计算机到计算机之间或应用程序的运行。如果应用程序必须坚持或传输数据,请参阅使用持久性本地化数据。
当此函数的ANSI版本,是使用一个Unicode只设置标识符,函数可以成功,因为操作系统使用系统代码页。然而,在字符系统代码页未定义出现在一个字符串问号(?)。
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderWinnls.h(头文件:winuser.h)
LibraryKernel32.lib
DLLKernel32.dll
Unicode和ANSI namesGetTimeFormatW(Unicode)和GetTimeFormatA(ANSI)的
参见
国家语言支持
国家语言支持功能
GetDateFormat
GetLocaleInfo
GetTimeFormatEx
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年7月12号
==英文原文==GetTimeFormat Function
Formats time as a time string for a locale specified by identifier. The function formats either a specified time or the local system time.
Note For interoperability reasons, the application should prefer the GetTimeFormatEx function to GetTimeFormat because Microsoft is migrating toward the use of locale names instead of locale identifiers for new locales. Any application that will be run only on Windows Vista and later should use GetTimeFormatEx .
Syntax
int GetTimeFormat(
__in LCID Locale,
__in DWORD dwFlags,
__in const SYSTEMTIME *lpTime,
__in LPCTSTR lpFormat,
__out LPTSTR lpTimeStr,
__in int cchTime
);
Parameters
Locale [in]
Locale identifier that specifies the locale. You can use the MAKELCID macro to create a locale identifier or use one of the following predefined values.
LOCALE_CUSTOM_DEFAULT
LOCALE_CUSTOM_UI_DEFAULT
LOCALE_CUSTOM_UNSPECIFIED
LOCALE_INVARIANT
LOCALE_SYSTEM_DEFAULT
LOCALE_USER_DEFAULT
dwFlags [in]
Flags specifying time format options. The application can specify a combination of the following values and LOCALE_USE_CP_ACP or LOCALE_NOUSEROVERRIDE .
Caution Use of LOCALE_NOUSEROVERRIDE is strongly discouraged as it disables user preferences.
ValueMeaning
TIME_NOMINUTESORSECONDSDo not use minutes or seconds.
TIME_NOSECONDSDo not use seconds.
TIME_NOTIMEMARKERDo not use a time marker.
TIME_FORCE24HOURFORMATAlways use a 24-hour time format.

lpTime [in]
Optional. Pointer to a SYSTEMTIME structure that contains the time information to format. The application can set this parameter to NULL if the function is to use the current local system time.
lpFormat [in]
Optional. Pointer to a format picture to use to format the time string. If the application sets this parameter to NULL, the function formats the string according to the time format of the specified locale. If the application does not set the parameter to NULL, the function uses the locale only for information not specified in the format picture string, for example, the locale-specific time markers. For information about the format picture string, see the Remarks section.
lpTimeStr [out]
Optional. Pointer to a buffer in which this function retrieves the formatted time string.
cchTime [in]
Size, in TCHAR values, for the time string buffer indicated by lpTimeStr. Alternatively, the application can set this parameter to 0. In this case, the function returns the required size for the time string buffer, and does not use the lpTimeStr parameter.
Return Value
Returns the number of TCHAR values retrieved in the buffer indicated by lpTimeStr. If the cchTime parameter is set to 0, the function returns the size of the buffer required to hold the formatted time string, including a terminating null character.
This function returns 0 if it does not succeed. To get extended error information, the application can call GetLastError , which can return one of the following error codes:
ERROR_INSUFFICIENT_BUFFER. A supplied buffer size was not large enough, or it was incorrectly set to NULL.
ERROR_INVALID_FLAGS. The values supplied for flags were not valid.
ERROR_INVALID_PARAMETER. Any of the parameter values was invalid.
ERROR_OUTOFMEMORY. Not enough storage was available to complete this operation.
Remarks
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 English (United States).
The time values in the structure indicated 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 members of the SYSTEMTIME structure. These include: wYear, wMonth, wDayOfWeek, and wDay.
If TIME_NOMINUTESORSECONDS or TIME_NOSECONDS is specified, the function removes the separators preceding the minutes and/or seconds members.
If TIME_NOTIMEMARKER is specified, the function removes the separators 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.
The function returns no errors for a bad format string, but just forms the best possible time string. If more than two hour, minute, second, or time marker format pictures are passed in, the function defaults to two. For example, the only time marker pictures that are valid are "t" and "tt". If "ttt" is passed in, the function assumes "tt".
To obtain the time format without performing any actual formatting, the application should use the GetLocaleInfo function, specifying LOCALE_STIMEFORMAT .
The application can use the following elements to construct a format picture string. If spaces are used to separate the elements in the format string, these spaces appear in the same location in the output string. The letters must be in uppercase or lowercase as shown, for example, "ss", not "SS". Characters in the format string that are enclosed in single quotation marks appear in the same location and unchanged in the output string.
PictureMeaning
hHours with no leading zero for single-digit hours; 12-hour clock
hhHours with leading zero for single-digit hours; 12-hour clock
HHours with no leading zero for single-digit hours; 24-hour clock
HHHours with leading zero for single-digit hours; 24-hour clock
mMinutes with no leading zero for single-digit minutes
mmMinutes with leading zero for single-digit minutes
sSeconds with no leading zero for single-digit seconds
ssSeconds with leading zero for single-digit seconds
tOne character time marker string, such as A or P
ttMulti-character time marker string, such as AM or PM

For example, to get the time string

"11:29:40 PM"
the application should use the picture string

"hh':'mm':'ss tt"
This function can retrieve data from custom locales . Data is not guaranteed to be the same from computer to computer or between runs of an application. If your application must persist or transmit data, see Using Persistent Locale Data .
When the ANSI version of this function is used with a Unicode-only locale identifier, the function can succeed because the operating system uses the system code page. However, characters that are undefined in the system code page appear in the string as a question mark (?).
Requirements
Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderWinnls.h (include Windows.h)
LibraryKernel32.lib
DLLKernel32.dll
Unicode and ANSI namesGetTimeFormatW (Unicode) and GetTimeFormatA (ANSI)
See Also
National Language Support
National Language Support Functions
GetDateFormat
GetLocaleInfo
GetTimeFormatEx
Send comments about this topic to Microsoft
Build date: 7/12/2009
==原始网址==http://msdn.microsoft.com/en-us/library/dd318130(VS.85).aspx\n
随便看

 

windows api函数参考手册包含2258条windows api函数文档,详细介绍nodejs、java、rust调用windows api的方法技巧,是学习windows api编程的入门中文文档。

 

Copyright © 2004-2023 Winrtm.com All Rights Reserved
京ICP备2021023879号-40 更新时间:2024/10/6 13:20:17