473,766 Members | 2,159 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

COleDateTime.Fo rmat 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.Form at(_T("%Y-%m-%dT%H:%M:%S"));
isoDate = problemDate.For mat(_T("%Y-%m-%dT%H:%M:%S")); // problem!

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

_VALIDATE_RETUR N( ( 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 4207
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.For mat(_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::F ormat("%Y") with m_dt set to 0.0 fails with
invalid_paramet er
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.For mat(_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::F ormat("%Y") with m_dt set to 0.0 fails with
invalid_paramet er
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.For mat(_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::F ormat("%Y") with m_dt set to 0.0 fails with
invalid_paramet er
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
1227
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
2080
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 Access, the data are incorrectly plotted with an x-axis that begins with a date of 1900. Only by toggling from the option "chart by column" to "chart by row" and then back to "chart by column", can I get the correct date on the x-axis. The problem...
1
1740
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 requirement. Done in VBA using Access2003 Rick
0
931
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 in the database, but when the day is >= 13, all is ok. I searched to find a solution, it seems that the regional settings available in the control panel or via the SetLocaleInfo win32 sdk can solde the solution, provided that you set the short date...
5
8645
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 when the date state is not valid. But we may need to pass NULL dates (read from a database) to our COM clients! - Yes, this problem doesn't occur in Release version, but we can't have a Debug version that asserts from time to time :) A solution...
0
997
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 code. How do I read/write a file with COleDateTime classes? -- Tony H
2
1622
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 and not ATL. Is there a compiler directive or switch or namespace that I am missing that precludes this? Best regards, Bill
9
14612
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 the user leaves the textbox then the date should be displayed as
18
13045
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 1901. For Example: the number 3566839 is 27.11.07 7:00. To calculate this in Excel I use this: ="01.01.1901"+(A1/24-(REST(A1;24)/24))+ZEIT(REST(A1;24);0;0) (put 3566839 in field A1 and switch the format of the result-field to the corresponding...
0
9571
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10168
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9959
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9838
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8835
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7381
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6651
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3929
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2806
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.