tru64-unix-managers (formerly alpha-osf-managers) (1994-2012)
 help / color / mirror / Atom feed
* SUMMARY: TIME FORMAT & C2
@ 1997-07-22 19:12 Douglas Meldrum
  0 siblings, 0 replies; only message in thread
From: Douglas Meldrum @ 1997-07-22 19:12 UTC (permalink / raw)
  To: tru64-unix-managers


Morning,

Thanks to the quick replies of :

Brian H. Mayo <brian.mayo@brynmawr.edu> who suggested wirting up a PERL 
SCRIPT

Paul A Sand <pas@cisunix.unh.edu> whos gave forth the following command:
perl -e 'print scalar localtime 867287140, "\n";' and suggested the usage 
of "strftime"

Randy M. Hayman <haymanr@icefog.sois.alaska.edu> who was kind enough to 
send me a C program to do the conversion ( see --secs2date -- )

All of the above satisfie my needs. Thanks again to those above for the help.

      ._._._.
  Douglas Meldrum
Network Coordinator
  Delphi Supernet
     H.S.A.I.T.
      .-.-.-.
PENDING: Summary on Disabling System Accounts
REASON:  Still lacking information.



-----------------secs2date--------------------------------

#include        <stdio.h>               /* printf()     */
#include        <sys/time.h>            /* localtime()  */

static  char    *weekday[7] = {"Sun","Mon","Tues","Wed","Thu","Fri","Sat"};
static  char    *month[12] = 
{"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};
struct  tm      *time_struct;
char    date_str[32] = NULL;
time_t  seconds;

main(int argc, char *argv[])
{

        if( !argv[1] ) {
                fprintf(stdout, "usage:  %s <secs since epoch>\n", argv[0]);
                exit(1);
        }

        (time_t)seconds = atoi(*++argv);
        time_struct = localtime(&seconds);

        sprintf(&date_str[0], " %s %02d %s %04d %d:%02d:%02d",
                weekday[time_struct->tm_wday], time_struct->tm_mday,
		month[time_struct->tm_mon], time_struct->tm_year + 1900, 
		time_struct->tm_hour, time_struct->tm_min, time_struct->tm_sec);

        fprintf(stdout, "\t%u seconds post-epoch is %s\n", seconds, date_str);

        exit(0);
}
------------------------8<----------------------------


$ cc -o secs2date secs2date.c
$ secs2date 867287140
        867287140 seconds post-epoch is  Wed 25 Jun 1997 17:05:40

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1997-07-22 19:12 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1997-07-22 19:12 SUMMARY: TIME FORMAT & C2 Douglas Meldrum

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox