Article View: borland.public.cppbuilder.nativeapi
Article #6837Time Weirdness
From: Bart
Date: Tue, 05 Apr 2005 07:10
Date: Tue, 05 Apr 2005 07:10
50 lines
1888 bytes
1888 bytes
Hi,
When I compile the code from below the result is 2005-04-03 01:00. This is
strange because the result must be 2005-04-03 02:00
When I alter the hour value the result is:
hour : result
1 2005-04-03 01:00 OK
2 2005-04-03 01:00 NOT OK !!!
3 2005-04-03 03:00 OK
When I compile this under Microsoft Visual C++ This runs fine...
Regards,
Bart
#include <time.h>
#include <stdio.h>
#include <conio.h>
void main()
{
char Env[80];
struct tm *time_now;
struct tm time_check;
time_t t;
long yy=2005;
long mm=4;
long dd=3;
long hh=2;
long nn=0; // result must be 2005-04-03 02:00
time_check.tm_year = yy - 1900;
time_check.tm_mon = mm - 1;
time_check.tm_mday = dd;
time_check.tm_hour = hh;
time_check.tm_min = nn;
time_check.tm_sec = 0;
time_check.tm_isdst = -1;
t = mktime(&time_check);
time_now = localtime(&t);
strftime(Env, 80,"%y-%m-%d %H:%M:%S",time_now); printf("%s\n",Env);
getch();
}
Technical Details
Message-ID:
<42523a06$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news3.google.com!newshub.sdsu.edu!peer01.west.cox.net!cox.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,8350982df1406f9 X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Bart" <Nomail@Spam.com> Newsgroups: borland.public.cppbuilder.nativeapi Subject: Time Weirdness Date: Tue, 5 Apr 2005 09:10:47 +0200 Lines: 52 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2180 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 NNTP-Posting-Host: 194.171.5.81 Message-ID: <42523a06$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1112685062 194.171.5.81 (5 Apr 2005 00:11:02 -0800) Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news3.google.com!newshub.sdsu.edu!peer01.west.cox.net!cox.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail