网站首页  词典首页

请输入您要查询的函数:

 

术语 getdateformat
释义 GetDateFormat
语法:
int GetDateFormat(
__in LCID Locale,
__in DWORD dwFlags,
__in const SYSTEMTIME *lpDate,
__in LPCTSTR lpFormat,
__out LPTSTR lpDateStr,
__in int cchDate
);
GetDateFormat功能
作为该区域设置标识符指定的区域日期字符串格式的日期。函数的格式或者在指定日期或本地系统日期。
注意:对于互操作性的原因,应用程序应更喜欢GetDateFormatEx功能GetDateFormat,因为微软是对的,而不是新的区域设置的区域设置标识符地区名称的使用迁移。任何将只运行在Windows Vista和以后应使用GetDateFormatEx申请。
参数
区域设置 [in]
区域设置标识符指定的区域设置此功能的日期格式的字符串。您可以使用MAKELCID宏创建一个区域设置标识符或使用下列预定义的值之一。
LOCALE_CUSTOM_DEFAULT
LOCALE_CUSTOM_UI_DEFAULT
LOCALE_CUSTOM_UNSPECIFIED
LOCALE_INVARIANT
LOCALE_SYSTEM_DEFAULT
LOCALE_USER_DEFAULT
dwFlags [in]
旗指定的各种功能,可以设置如果lpFormat设置为NULL选项。应用程序可以指定下列值和LOCALE_USE_CP_ACP或LOCALE_NOUSEROVERRIDE组合。
警示LOCALE_NOUSEROVERRIDE强烈建议不要使用,因为它禁用用户的喜好。
ValueMeaning
DATE_AUTOLAYOUTWindows 7和更高版本:侦测从右到左的需要和左到右阅读使用区域设置布局和日历信息,并添加相应的标记。此值不能用于DATE_LTRREADING或DATE_RTLREADING。 DATE_AUTOLAYOUT是优于DATE_LTRREADING和DATE_RTLREADING,因为它使用的语言环境和日历,以确定正确的商标增加。
DATE_LONGDATEUse长日期格式。此值不能用于DATE_SHORTDATE或DATE_YEARMONTH。
为左到右阅读布局DATE_LTRREADINGAdd马克。此值不能用于DATE_RTLREADING。
为从右到DATE_RTLREADINGAdd商标左阅读布局。可此值不能用于DATE_LTRREADING
DATE_SHORTDATEUse的短日期格式。这是默认的。此值不能用于DATE_LONGDATE或DATE_YEARMONTH。
DATE_USE_ALT_CALENDARUse备用日历,如果存在,格式化日期字符串。如果设置此标志,函数使用的备用日历默认格式,而不使用任何用户覆盖。用户覆盖将仅用于如果没有指定的备用日历的默认格式。
DATE_YEARMONTHWindows景色:使用年/月格式。此值不能用于DATE_SHORTDATE或DATE_LONGDATE。
如果应用程序没有指定DATE_YEARMONTH,DATE_SHORTDATE,或DATE_LONGDATE和lpFormat设置为NULL,DATE_SHORTDATE是默认的。
lpDate [in]
可选。指针SYSTEMTIME结构,它包含最新信息的格式。应用程序设置此参数为NULL,如果该函数使用当前本地系统日期。
lpFormat [in]
可选。指针图片的格式字符串,用来形成的日期。图片的格式字符串可能的值定义在日,月,年,和时代格式图片。
该函数使用唯一没有在字符串中指定格式的图片资料,指定的语言环境,例如,区域设置的日期和月份的名称。应用程序可以将此参数设置为NULL,以格式化字符串按照指定区域设置的日期格式。
lpDateStr [out]
可选。缓冲区指针在本函数检索格式化的日期字符串。
cchDate [in]
大小,以字符,在lpDateStr缓冲区。应用程序可以设置为0参数来返回缓冲区大小须持有格式化的日期字符串。在这种情况下,缓冲区由lpDateStr表示不使用。
返回值
返回的数目写入lpDateStr缓冲区字符如果成功。如果cchDate参数设置为0,则函数返回须持有格式化日期字符串中的字符,包括终止空字符。
该函数返回0,如果没有成功。为了获得更多错误信息,应用程序可以调用GetLastError函数,可以返回以下错误代码之一:
ERROR_INSUFFICIENT_BUFFER。阿提供的缓冲区大小不够大,或者被错误地设置为NULL。
ERROR_INVALID_FLAGS。旗帜提供的值不是有效的。
ERROR_INVALID_PARAMETER。该参数值的任何无效。
备注
最早的日期此功能的支持,是1601年1月1日。
这一天的名称,名称缩写一天,一个月的名称,缩写月份名称都是本地化的基础上的区域设置标识符。
在结构方面所显示的日期值lpDate必须是有效的。该函数检查日期的每个值:年,月,日和星期几。如果星期不正确,使用正确的函数值,并没有返回错误。如果任何其他日期值正确的范围之外的是,该功能失败,并设置最后一个错误的ERROR_INVALID_PARAMETER。
该函数忽略了SYSTEMTIME结构成员的时间由lpDate表示。这些措施包括wHour,wMinute,wSecond和wMilliseconds。
如果lpFormat参数包含一个坏格式字符串,该函数没有返回错误,而是形成了最好的日期字符串。例如,图片,只有一年的有效期为L“月月”和L“月月”,其中的“L”表示一个Unicode(16位字符)字符串。如果L“y”是传递,函数假定升“月月”。如果L“yyy”的通过,该函数假定升“月月”。如果超过4日(长“dddd将”)或4个月(长“MMMM”)通过图片,函数默认为L“dddd将”或L“MMMM”。
应用程序应该包括任何文字,应继续其在该日期格式图片在单引号的确切日期字符串形式。单引号也可以用来作为转义字符,使单引号自己是在显示的日期字符串。然而,转义序列必须是密封在两个单引号。例如,要显示日期为“93月”,格式字符串是:长“MMMM '' ''月月”。第一个和最后一个单引号封闭引号。第二和第三的单引号的转义序列,使单引号之前要显示的世纪。
当日期图片包含一个一天数字形式(无论是D或DD)和完整的月份名称(MMMM),该月的名称所有格形式的检索日期字符串。
要获取不进行任何实际的格式默认的短期和长期的日期格式,应用程序应使用GetLocaleInfo与LOCALE_SSHORTDATE或LOCALE_SLONGDATE不变。要获得替代日历上的日期格式,应用程序使用同LOCALE_IOPTIONALCALENDAR不断GetLocaleInfo。要获得特定日历日期的格式,应用程序使用GetCalendarInfo。它可以调用EnumCalendarInfo或EnumDateFormatsEx以检索特定日历日期格式。
这个功能可以自定义区域设置检索数据。数据不能保证从同一计算机到计算机之间或应用程序的运行。如果应用程序必须坚持或传输数据,请参阅使用持久性本地化数据。
当此函数的ANSI版本,是使用一个Unicode只设置标识符,函数可以成功,因为操作系统使用系统代码页。然而,在字符系统代码页未定义出现在一个问号("?").串
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderWinnls.h(头文件:winuser.h)
LibraryKernel32.lib
DLLKernel32.dll
Unicode和ANSI namesGetDateFormatW(Unicode)和GetDateFormatA(ANSI)的
参见
国家语言支持
国家语言支持功能
日,月,年,和时代格式图片
EnumCalendarInfo
EnumDateFormatsEx
GetCalendarInfo
GetDateFormatEx
GetLocaleInfo
GetTimeFormat
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年7月12号
==英文原文==GetDateFormat Function
Formats a date as a date string for a locale specified by the locale identifier. The function formats either a specified date or the local system date.
Note For interoperability reasons, the application should prefer the GetDateFormatEx function to GetDateFormat 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 GetDateFormatEx .
Syntax
int GetDateFormat(
__in LCID Locale,
__in DWORD dwFlags,
__in const SYSTEMTIME *lpDate,
__in LPCTSTR lpFormat,
__out LPTSTR lpDateStr,
__in int cchDate
);
Parameters
Locale [in]
Locale identifier that specifies the locale this function formats the date string for. 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 various function options that can be set if lpFormat is set to NULL. 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
DATE_AUTOLAYOUTWindows 7 and later: Detect the need for right-to-left and left-to-right reading layout using the locale and calendar information, and add marks accordingly. This value cannot be used with DATE_LTRREADING or DATE_RTLREADING. DATE_AUTOLAYOUT is preferred over DATE_LTRREADING and DATE_RTLREADING because it uses the locales and calendars to determine the correct addition of marks.
DATE_LONGDATEUse the long date format. This value cannot be used with DATE_SHORTDATE or DATE_YEARMONTH.
DATE_LTRREADINGAdd marks for left-to-right reading layout. This value cannot be used with DATE_RTLREADING.
DATE_RTLREADINGAdd marks for right-to-left reading layout. This value cannot be used with DATE_LTRREADING
DATE_SHORTDATEUse the short date format. This is the default. This value cannot be used with DATE_LONGDATE or DATE_YEARMONTH.
DATE_USE_ALT_CALENDARUse the alternate calendar, if one exists, to format the date string. If this flag is set, the function uses the default format for that alternate calendar, rather than using any user overrides. The user overrides will be used only in the event that there is no default format for the specified alternate calendar.
DATE_YEARMONTHWindows Vista: Use the year/month format. This value cannot be used with DATE_SHORTDATE or DATE_LONGDATE.

If the application does not specify DATE_YEARMONTH, DATE_SHORTDATE, or DATE_LONGDATE, and lpFormat is set to NULL, DATE_SHORTDATE is the default.
lpDate [in]
Optional. Pointer to a SYSTEMTIME structure that contains the date information to format. The application sets this parameter to NULL if the function is to use the current local system date.
lpFormat [in]
Optional. Pointer to a format picture string that is used to form the date. Possible values for the format picture string are defined in Day, Month, Year, and Era Format Pictures .
The function uses the specified locale only for information not specified in the format picture string, for example, the day and month names for the locale. The application can set this parameter to NULL to format the string according to the date format for the specified locale.
lpDateStr [out]
Optional. Pointer to a buffer in which this function retrieves the formatted date string.
cchDate [in]
Size, in characters, of the lpDateStr buffer. The application can set this parameter to 0 to return the buffer size required to hold the formatted date string. In this case, the buffer indicated by lpDateStr is not used.
Return Value
Returns the number of characters written to the lpDateStr buffer if successful. If the cchDate parameter is set to 0, the function returns the number of characters required to hold the formatted date string, including the terminating null character.
The 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.
Remarks
The earliest date supported by this function is January 1, 1601.
The day name, abbreviated day name, month name, and abbreviated month name are all localized based on the locale identifier.
The date values in the structure indicated 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 function ignores the time members of the SYSTEMTIME structure indicated by lpDate. These include wHour, wMinute, wSecond, and wMilliseconds.
If the lpFormat parameter contains a bad format string, the function returns no errors, but just forms the best possible date string. For example, the only year pictures that are valid are L"yyyy" and L"yy", where 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 four date (L"dddd") or four month (L"MMMM") pictures are passed in, the function defaults to L"dddd" or L"MMMM".
The application should enclose any text that should remain in its exact form in the date string within single quotation marks in the date format picture. The single quotation mark can also be used as an escape character to allow the single quotation mark itself to be displayed in the date string. However, the escape sequence must be enclosed within two single quotation marks. For example, to display the date as "May '93", the format string is: L"MMMM ''''yy". The first and last single quotation marks are the enclosing quotation marks. The second and third single quotation marks are the escape sequence to allow the single quotation mark to be displayed before the century.
When the date picture contains both a numeric form of the day (either d or dd) and the full month name (MMMM), the genitive form of the month name is retrieved in the date string.
To obtain the default short and long date format without performing any actual formatting, the application should use GetLocaleInfo with the LOCALE_SSHORTDATE or LOCALE_SLONGDATE constant. To get the date format for an alternate calendar, the application uses GetLocaleInfo with the LOCALE_IOPTIONALCALENDAR constant. To get the date format for a particular calendar, the application uses GetCalendarInfo . It can call EnumCalendarInfo or EnumDateFormatsEx to retrieve date formats for a particular calendar.
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 namesGetDateFormatW (Unicode) and GetDateFormatA (ANSI)
See Also
National Language Support
National Language Support Functions
Day, Month, Year, and Era Format Pictures
EnumCalendarInfo
EnumDateFormatsEx
GetCalendarInfo
GetDateFormatEx
GetLocaleInfo
GetTimeFormat
Send comments about this topic to Microsoft
Build date: 7/12/2009
==原始网址==http://msdn.microsoft.com/en-us/library/dd318086(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 11:32:28