tru64-unix-managers (formerly alpha-osf-managers) (1994-2012)
 help / color / mirror / Atom feed
From: Douglas Meldrum <arn () oracle ! dsuper ! net>
To: tru64-unix-managers
Subject: SUMMARY: TIME FORMAT & C2
Date: Tue, 22 Jul 1997 19:12:58 +0000	[thread overview]
Message-ID: <96078614710517.tru64-unix-managers.marc@archive.invalid> (raw)


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

                 reply	other threads:[~1997-07-22 19:12 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed
read-only archive

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