Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

localtime and DST

8 views
Skip to first unread message

Banjolicious

unread,
Oct 27, 2008, 2:17:47 PM10/27/08
to
Not sure which group this belongs in, so I'll start here:

I ran across a problem with the way localtime is working on BCB6 with
respect to Daylight Saving Time. The following code snippet produces
the output that follows. Note how it wraps from 2:55 to 2:00 in the
output. I suspect everything after 2am is labeled incorrectly:

void __fastcall TForm1::Button1Click(TObject *Sender)
{
struct tm *result;
String sMsg;

time_t t = (time_t) 1225004400U - 4800U;

Memo1->Clear();
Memo1->Lines->Add( " time_t\t localtime");
for( int i = 0; i < 50; i++ )
{
t = t + 300;
result = localtime( &t );
sMsg = String( t ) + "\t" + asctime( result );
Memo1->Lines->Add( sMsg );
}
}

The output:
time_t localtime
1224999900 Sun Oct 26 01:45:00 2008

1225000200 Sun Oct 26 01:50:00 2008

1225000500 Sun Oct 26 01:55:00 2008

1225000800 Sun Oct 26 02:00:00 2008

1225001100 Sun Oct 26 02:05:00 2008

1225001400 Sun Oct 26 02:10:00 2008

1225001700 Sun Oct 26 02:15:00 2008

1225002000 Sun Oct 26 02:20:00 2008

1225002300 Sun Oct 26 02:25:00 2008

1225002600 Sun Oct 26 02:30:00 2008

1225002900 Sun Oct 26 02:35:00 2008

1225003200 Sun Oct 26 02:40:00 2008

1225003500 Sun Oct 26 02:45:00 2008

1225003800 Sun Oct 26 02:50:00 2008

1225004100 Sun Oct 26 02:55:00 2008

1225004400 Sun Oct 26 02:00:00 2008

1225004700 Sun Oct 26 02:05:00 2008

1225005000 Sun Oct 26 02:10:00 2008

1225005300 Sun Oct 26 02:15:00 2008

0 new messages