473,395 Members | 1,412 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

COleDateTime.Format can't deal with year before 1900

This is a problem present using Visual Studio 2005, but not in Visual
Studio 2003 or Visual C++ 6.

COleDateTime modernDate( 1900, 1, 1, 0, 1, 0 );
COleDateTime problemDate( 1753, 1, 1, 0, 1, 0 );

CString isoDate = modernDate.Format(_T("%Y-%m-%dT%H:%M:%S"));
isoDate = problemDate.Format(_T("%Y-%m-%dT%H:%M:%S")); // problem!

problemDate.Format triggers an assertion failure on line 783 of strftime.c:

_VALIDATE_RETURN( ( timeptr->tm_year >=0 ), EINVAL, FALSE)

So any date where the year is earlier than 1900 will result in
timeptr->tm_year containing a negative value and fail the assertion on
line 783 of strftime.c if %Y is requested in the format string.

Is this a bug, or am I missing something?

Thanks,
Ian
Jan 25 '06 #1
5 4188
Hi Ian!
COleDateTime problemDate( 1753, 1, 1, 0, 1, 0 );


I think this is not allowed:
<quote>
The DATE type is implemented as a floating-point value, measuring days
from midnight, 30 December 1899. So, midnight, 31 December 1899 is
represented by 1.0. Similarly, 6 AM, 1 January 1900 is represented by
2.25, and midnight, 29 December 1899 is – 1.0. However, 6 AM, 29
December 1899 is – 1.25.
</quote>

--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/
Jan 25 '06 #2
Sorry... I forgot about the negativ numbers ;-(

<quote>
The COleDateTime class handles dates from 1 January 100 – 31 December 9999.
</quote>

--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/
Jan 25 '06 #3
Hi Ian!
This is a problem present using Visual Studio 2005, but not in Visual
Studio 2003 or Visual C++ 6.

COleDateTime problemDate( 1753, 1, 1, 0, 1, 0 );
isoDate = problemDate.Format(_T("%Y-%m-%dT%H:%M:%S")); // problem!


The simplest repro-code is:

COleDateTime dt( 1753, 1, 1, 0, 1, 0 );
CString year = dt.Format(_T("%Y"));

It seems that this is a bug... of course there are a entry in ladybug:

COleDateTime::Format("%Y") with m_dt set to 0.0 fails with
invalid_parameter
http://lab.msdn.microsoft.com/produc...d-e15981250119

It seems that the bug is fixed but not yet available to public...
If you need a hotfix you might ask Product support to get one.

--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/
Jan 25 '06 #4
Jochen Kalmbach [MVP] wrote:
Hi Ian!
This is a problem present using Visual Studio 2005, but not in Visual
Studio 2003 or Visual C++ 6.

COleDateTime problemDate( 1753, 1, 1, 0, 1, 0 );
isoDate = problemDate.Format(_T("%Y-%m-%dT%H:%M:%S")); // problem!

The simplest repro-code is:

COleDateTime dt( 1753, 1, 1, 0, 1, 0 );
CString year = dt.Format(_T("%Y"));

It seems that this is a bug... of course there are a entry in ladybug:

COleDateTime::Format("%Y") with m_dt set to 0.0 fails with
invalid_parameter
http://lab.msdn.microsoft.com/produc...d-e15981250119
It seems that the bug is fixed but not yet available to public...
If you need a hotfix you might ask Product support to get one.


Thank you. At least it is confirmed as a bug. I didn't know MS bugs
were accessible online, that's useful to know.

Ian
Jan 26 '06 #5
Does anyone know what the hotfix number is for this issue? I contacted
Microsoft Professional Support here in Sweden but they could not find it and
the bug id (FDBK26782) didn't seem to help them.

Thanks!

/Henrik

"Jochen Kalmbach [MVP]" wrote:
Hi Ian!
This is a problem present using Visual Studio 2005, but not in Visual
Studio 2003 or Visual C++ 6.

COleDateTime problemDate( 1753, 1, 1, 0, 1, 0 );
isoDate = problemDate.Format(_T("%Y-%m-%dT%H:%M:%S")); // problem!


The simplest repro-code is:

COleDateTime dt( 1753, 1, 1, 0, 1, 0 );
CString year = dt.Format(_T("%Y"));

It seems that this is a bug... of course there are a entry in ladybug:

COleDateTime::Format("%Y") with m_dt set to 0.0 fails with
invalid_parameter
http://lab.msdn.microsoft.com/produc...d-e15981250119

It seems that the bug is fixed but not yet available to public...
If you need a hotfix you might ask Product support to get one.

--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/

Feb 22 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: MLH | last post by:
If I run this... For i = -1 To -12 Step -1 Debug.Print CStr(Month(DateAdd("m", i, Now))) & "/"; CStr(Year(DateAdd("m", i, Now))) Next i I get this... 5/2005 4/2005 3/2005
0
by: spm_no | last post by:
Hi, I am using Access 2002 and am creating a scatter-chart on a form in which the X-axis is a date. I can format and display the x-axis properly as a date. However, when I close and reopen...
1
by: 2D Rick | last post by:
I open a InputBox for specific formatted data and pass return to a variable. The format and length remain constant: yyCC looks like 05MR Is there a quick way to verify the input meets the format...
0
by: fwidget | last post by:
Hi All, I actually encounter a problem when storing COleDatetime in an Access97 database, when the COleDateTime day is <= 12, the day and month are swapped when I look at the record newly inserted...
5
by: Paolo | last post by:
We are experiencing a problem with COleDateTime while migrating our MFC&ATL project from VC++6.0 to VC++7.1 (Visual Studio .NET 2003). COleDateTime has a DATE conversion operator that in 7.1 asserts...
0
by: Tony H | last post by:
When I try to serialize COleDateTime, I get " binary '>>' : no operator found which takes a right-hand operand of type 'ATL::COleDateTime'". I have a file being shared by both VS6 and VS2005...
2
by: AST | last post by:
Hey, Can anybody tell me why the ATL::ColeDateTime implementation is referenced rather than the MFC implementation? The method GetAsDBTIMESTAMP(...) is only available on the MFC implementation...
9
by: samuelberthelot | last post by:
Hi, Here is what I'm trying to achieve: The user enters in the textbox a date. It can be: 02.05.2006 or any other separator... 02052006 020506 any other formats should be forbidden. When...
18
by: Dirk Hagemann | last post by:
Hello, From a zone-file of a Microsoft Active Directory integrated DNS server I get the date/time of the dynamic update entries in a format, which is as far as I know the hours since january 1st...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.