From: Georg Krichel on
This code (unmanaged C++, Visual Studio 2005)

for( int d = 1; d < 8; ++d )
{
cout << endl;
tm t;
t.tm_year = 70;
t.tm_mon = 0;
t.tm_mday = d;
t.tm_hour = 0;
t.tm_min = 0;
t.tm_sec = 0;
t.tm_isdst = -1;
cout << t.tm_year + 1900 << '-' << t.tm_mon + 1 << '-' << t.tm_mday
<< endl;
mktime( &t ); // == _mktime64( &t );
const char* bug = ( t.tm_mday != d ) ? " <-- BUG?" : "";
cout << t.tm_year + 1900 << '-' << t.tm_mon + 1 << '-' << t.tm_mday
<< bug << endl;
}

produces this output:

1970-1-1
1970-1-1

1970-1-2
1970-1-1 <-- BUG?

1970-1-3
1970-1-2 <-- BUG?

1970-1-4
1970-1-3 <-- BUG?

1970-1-5
1970-1-5

1970-1-6
1970-1-6

1970-1-7
1970-1-7

Question:
Is date adjustment correct for dates Jan 2, 1970 to Jan 4, 1970?
I don't think so.

Greetings from Cologne (Germany)
Georg Krichel

From: David Lowndes on
>This code (unmanaged C++, Visual Studio 2005)
>
>for( int d = 1; d < 8; ++d )
>{
> cout << endl;
> tm t;
> t.tm_year = 70;
> t.tm_mon = 0;
> t.tm_mday = d;
> t.tm_hour = 0;
> t.tm_min = 0;
> t.tm_sec = 0;
> t.tm_isdst = -1;
> cout << t.tm_year + 1900 << '-' << t.tm_mon + 1 << '-' << t.tm_mday
> << endl;
> mktime( &t ); // == _mktime64( &t );
> const char* bug = ( t.tm_mday != d ) ? " <-- BUG?" : "";
> cout << t.tm_year + 1900 << '-' << t.tm_mon + 1 << '-' << t.tm_mday
> << bug << endl;
>}
>
>produces this output:
>...
>1970-1-2
>1970-1-1 <-- BUG?

Georg,

I can't repro this.

Are you using any particular compiler settings?

Dave
From: Tom Widmer [VC++ MVP] on
Georg Krichel wrote:
> This code (unmanaged C++, Visual Studio 2005)
[snip]
> 1970-1-2
> 1970-1-1 <-- BUG?
>
> 1970-1-3
> 1970-1-2 <-- BUG?
>
> 1970-1-4
> 1970-1-3 <-- BUG?
>
> 1970-1-5
> 1970-1-5
>
> 1970-1-6
> 1970-1-6
>
> 1970-1-7
> 1970-1-7
>
> Question:
> Is date adjustment correct for dates Jan 2, 1970 to Jan 4, 1970?

It certainly seems wrong.

> I don't think so.
>
> Greetings from Cologne (Germany)

I managed to reproduce the problem by setting my time zone to match
yours (Berlin).

Tom
From: David Lowndes on
>I managed to reproduce the problem by setting my time zone to match
>yours (Berlin).

Curious. I've just set mine to Berlin too - still no repro for me. I
have VS2005 SP1 beta installed though!

Dave