| |
| LPTSTR FormatDate( |
| |
LONGLONG nSeconds, |
|
| |
LONG nTimezone, |
|
| |
LPTSTR lpszDate, |
|
| |
INT cchMaxDate |
|
| ); |
| LPTSTR FormatDate( |
| |
LONGLONG nSeconds, |
|
| |
LPTSTR lpszDate, |
|
| |
INT cchMaxDate |
|
| ); |
| LPTSTR FormatDate( |
| |
LONGLONG nSeconds, |
|
| |
LONG nTimezone, |
|
| |
CString& strDate |
|
| ); |
| LPTSTR FormatDate( |
| |
LONGLONG nSeconds, |
|
| |
CString& strDate |
|
| ); |
The FormatDate converts the specified date, expressed as
the number of seconds since 1 January 1970, into a string compatible
with the RFC 822 standard format for email messages.
Parameters
- nSeconds
- A 64-bit integer which specifies the number of seconds since 1
January 1970 00:00:00 UTC. This date is commonly called the epoch,
and is the base date used by the standard C/C++ time methods. If the
value of this parameter is zero, the current date and time is
used.
- nTimezone
- A 32-bit integer which is set to the difference in
seconds between the specified date's timezone and Coordinated
Universal Time. A value of zero
specifies Coordinated Universal Time, while a positive value
specifies a timezone west of UTC, and a negative value specifies a
timezone east of UTC. For example, the Eastern timezone would be
specified as the value 18000 and the Pacific timezone would be the
value 28800. If this argument is omitted from the method, then the
current timezone is used.
- lpszDate
- A buffer which will contain the formatted date as a
null-terminated string. This parameter cannot be a NULL
pointer.
- cchMaxDate
- The maximum number of characters, including the terminating
null character, which may be copied into the date string buffer.
Return Value
If the method succeeds, a pointer to the date string buffer is
returned. If the method fails, a NULL pointer is returned. To get
extended error information, call GetLastError.
Remarks
The date string is returned in a standard format as outlined in
RFC 822, the document which describes the basic structure of Internet
email messages. This format is as follows:
www, dd mmm yyyy hh:mm:ss [-]zzzz
Each part of the date string is defined as follows:
| Format |
Description |
| www |
Weekday |
| dd |
Day |
| mmm |
Month |
| yyyy |
Year |
| hh |
Hour (24-hour clock) |
| mm |
Minutes |
| ss |
Seconds |
| zzzz |
Timezone |
The weekday and month are displayed using standard three-character
English abbreviations. The timezone is displayed as the difference
(in hours and minutes) between the specified timezone and Coordinated
Universal Time. For example, if the timezone is eight hours west of
Coordinated Universal Time, the nTimezone value would be
28800. This would be displayed as -0800 in the formatted date
string.
Note that the format of the date string is defined by the RFC 822
standard, and is not affected by localization settings on the host
system.
Previous versions of this method represented date and time values
as 32-bit integers, which limited the representable range to dates
before 19 January 2038 (the so-called "Year 2038 problem").
After this date, 32-bit time values will overflow, resulting in incorrect
date calculations and potential failures in software that processes email
message dates. By contrast, this 64-bit version uses 64-bit integer
values, matching the standard time_t type used by modern
C/C++ libraries. This not only eliminates the Year 2038 limitation but
also ensures compatibility with current and future systems, allowing
correct handling of dates both far in the past and well into the future.
Whenever possible, applications should transition to these 64-bit
functions to ensure long-term reliability and portability.
Requirements
Minimum Desktop Platform: Windows 7 Service Pack 1
Minimum Server Platform: Windows Server 2008 R2 Service Pack 1
Header File: cstools12.h
Import Library: csmsgv12.lib
Unicode: Implemented as Unicode and ANSI versions
See Also
|
|