|
|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T u
Length: 1926 (0x786)
Types: TextFile
Names: »ut2tm.c«
└─⟦3d0c2be1b⟧ Bits:30001254 ISODE-5.0 Tape
└─⟦eba4602b1⟧ »./isode-5.0.tar.Z«
└─⟦d3ac74d73⟧
└─⟦this⟧ »isode-5.0/psap/ut2tm.c«
/* ut2tm.c - time string to tm */
#ifndef lint
static char *rcsid = "$Header: /f/osi/psap/RCS/ut2tm.c,v 6.0 89/03/18 23:39:37 mrose Rel $";
#endif
/*
* $Header: /f/osi/psap/RCS/ut2tm.c,v 6.0 89/03/18 23:39:37 mrose Rel $
*
*
* $Log: ut2tm.c,v $
* Revision 6.0 89/03/18 23:39:37 mrose
* Release 5.0
*
*/
/*
* NOTICE
*
* Acquisition, use, and distribution of this module and related
* materials are subject to the restrictions of a license agreement.
* Consult the Preface in the User's Manual for the full terms of
* this agreement.
*
*/
/* LINTLIBRARY */
#include <stdio.h>
#include "psap.h"
#ifdef OSX
#include <sys/time.h>
#endif
#define UNYEAR(y) ((y) < 1900 || (y) > 1999 ? (y) : (y) - 1900)
extern int dmsize[];
/* \f
*/
struct tm *ut2tm (ut)
register UTC ut;
{
static struct tm tms;
register struct tm *tm = &tms;
bzero ((char *) tm, sizeof *tm);
tm -> tm_sec = ut -> ut_sec;
tm -> tm_min = ut -> ut_min;
tm -> tm_hour = ut -> ut_hour;
tm -> tm_mday = ut -> ut_mday;
tm -> tm_mon = ut -> ut_mon - 1;
tm -> tm_year = UNYEAR (ut -> ut_year);
tm -> tm_wday = tm -> tm_yday = tm -> tm_isdst = 0;
tm -> tm_hour -= ut -> ut_zone / 60, tm -> tm_min -= ut -> ut_zone % 60;
if (tm -> tm_min < 0)
tm -> tm_hour--, tm -> tm_min += 60;
else
if (tm -> tm_min > 59)
tm -> tm_hour++, tm -> tm_min -= 60;
/* this ignores odditites in February... */
if (tm -> tm_hour < 0) {
tm -> tm_mday++, tm -> tm_hour += 24;
if (tm -> tm_mday > dmsize[tm -> tm_mon]) {
tm -> tm_mon++, tm -> tm_mday = 1;
if (tm -> tm_mon > 11)
tm -> tm_year++, tm -> tm_mon = 0;
}
}
else
if (tm -> tm_hour > 23) {
tm -> tm_mday--, tm -> tm_hour -= 24;
if (tm -> tm_mday < 1) {
tm -> tm_mday = dmsize[--tm -> tm_mon];
if (tm -> tm_mon < 0)
tm -> tm_year--, tm -> tm_mon = 11;
}
}
return tm;
}