www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/08/02/02:02:57.1

From: NoSpam AT Ever DOT Com (Radical NetSurfer)
Newsgroups: comp.os.msdos.djgpp
Subject: EUREKA!
Message-ID: <37a62f9a.414468@news.erie.net>
References: <1 DOT 5 DOT 4 DOT 16 DOT 19990801230707 DOT 337fc54a AT erie DOT net> <37A51FC7 DOT 167A7916 AT a DOT crl DOT com>
X-Newsreader: Forte Agent 1.5/32.452
MIME-Version: 1.0
Lines: 84
NNTP-Posting-Host: 208.166.66.14
X-Trace: typ12.nn.bcandid.com 933572794 208.166.66.14 (Mon, 02 Aug 1999 01:46:34 EDT)
NNTP-Posting-Date: Mon, 02 Aug 1999 01:46:34 EDT
Date: Mon, 02 Aug 1999 05:46:18 GMT
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

I figured this out BEFORE the reply contained below, but I do
thank you for the confirmation.

EUREKA!  I did it...finally...

/* This DJGPP program PROPERLY displays the
   Current Date/Time (as set by the PC's system time).

   The purpose of this program is to simply demonstrate 
   how DJGPP compares to Borland (and other compilers)
   in compatibility, compilation speed, execuation speed,
   and a host of other details!

The following program clearly shows the proper way to use
the structures
   struct tm *time_now;
   time_t secs_now;
and the funcitons:
   prinft, strcpy
   time(),
   localtime(),
   strftime();  //a really jazzie way to output Date/Time !!

This actually compiles IDENTICALLY (ie: NO CHANGES) in
Borland 4.xx and 5.xx !!
*/		

#include <stdio.h>
#include <string.h>
#include <time.h>

   struct tm *time_now;
   time_t secs_now;

int main(void) {
char buf1[100];
char buf2[100];

   time(&secs_now);
   time_now = localtime(&secs_now);

  strcpy( buf1, asctime(localtime(&secs_now)) );
  strftime(buf2, 80,
            "It is %M minutes after %I o'clock (%Z)  %A, %B %d 19%y",
             time_now);

printf("The current date/time is %s", buf1 );
printf("The current date/time is %s", buf2 );

return 0;
}

/* Outputs:
     The Current Date/Time!!
*/
===========================================================

On Sun, 01 Aug 1999 23:34:15 -0500, Weiqi Gao <weiqigao AT a DOT crl DOT com>
wrote:

>Rich wrote:

That was in reference to what another poster had said, somewhat
rudely.  If you follow the ListServ messages, you'll understand.
    
>New comers are never treated harshly in this newsgroup.  Considering
>that this news group has a fantastic FAQ, I don't think a "beginner"
>newsgroup would be necessary.  And in general a group for "beginner"s
>would never work: who's going to ANSWER all the beginner questions?
>
>> I still would like to see a working example of    strftime
>> since I haven't been successful getting the LIBC.hlp
>> example to work for me yet.
>
>time_t now;
>char buf[100];
>time(&now);
>strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", localtime(&now));
>
>This should give you something like "1999-08-01 22:59:56".

My web page:
http://members.tripod.com/~RadSurfer/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019