On Wed, 14 Aug 2019 18:48:22 -0400, Phil Smith III <[email protected]> wrote:

>Poked around some more, found
>
>https://groups.google.com/forum/#!msg/bit.listserv.ibm-main/mYYcbXg0lGY/hu0cNy5TO30J
>
>which looked promising, but this:
>  [ ... ]
A few suggestions:
Do you also need the date?  That should be derived from the same
call to time(); lest midnight intrude.

615 $ cat when.c
  #include <time.h>
  #include <stdio.h>
  #include <stdlib.h>
  #include <string.h>

  time_t ltime;

  static char hhmmss[9];

  struct tm *tmptr;
 
int main( int argc, char **argv ) {
   time(&ltime);

   if ( ! getenv( "TZ" ) )  /* Support caller's setting of TZ.  */
       setenv("TZ","CST6CDT",1);

   tzset();

   tmptr = localtime(&ltime);

/* timeptr = asctime(tmptr);
   memcpy(&hhmmss, timeptr+11, 8);
   hhmmss[8] = 0;
   Deprecated; see 
http://pubs.opengroup.org/onlinepubs/9699919799/functions/asctime.html#tag_16_21_07
   So:  */
   strftime( hhmmss, 9, "%H:%M:%s\0", tmptr );

   printf( "%s\n", hhmmss);  /* show result.  */
   return( 0 );
}
-- gil

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to