Annotation of researchv8dc/cmd/cyntax/cem/time.c, revision 1.1

1.1     ! root        1: #include       <time.h>
        !             2: #include       "cem.h"
        !             3: 
        !             4: /*
        !             5:  *     Return a sstring representation of a time.  If it is
        !             6:  *     the same year as now leave out the year.  If it is the
        !             7:  *     same day and we aren't being pedantic leave out the date.
        !             8:  */
        !             9: char   *
        !            10: stime(t)
        !            11: long   t;
        !            12: {
        !            13:        register struct tm      *tp;
        !            14:        register char           *p;
        !            15:        static struct tm        this;
        !            16:        static long             now;
        !            17:        extern char             *ctime();
        !            18:        extern long             time();
        !            19:        extern struct tm        *localtime();
        !            20: 
        !            21:        if (now == 0)
        !            22:        {
        !            23:                now = time((long *)0);
        !            24:                this = *localtime(&now);
        !            25:        }
        !            26: 
        !            27:        tp = localtime(&t);
        !            28:        p = ctime(&t);
        !            29: 
        !            30:        if (tp->tm_year == this.tm_year)
        !            31:                p[19] = '\0';
        !            32:        else
        !            33:                p[24] = '\0';
        !            34: 
        !            35:        if
        !            36:        (
        !            37:                !pedantic
        !            38:                &&
        !            39:                tp->tm_mon == this.tm_mon
        !            40:                &&
        !            41:                tp->tm_mday == this.tm_mday
        !            42:                &&
        !            43:                tp->tm_year == this.tm_year
        !            44:        )
        !            45:                return p + 11;
        !            46:        else
        !            47:                return p;
        !            48: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.