/* ut2tm.c - time string to tm */
static char *rcsid
= "$Header: /f/osi/psap/RCS/ut2tm.c,v 7.1 91/02/22 09:37:17 mrose Interim $";
* $Header: /f/osi/psap/RCS/ut2tm.c,v 7.1 91/02/22 09:37:17 mrose Interim $
* Revision 7.1 91/02/22 09:37:17 mrose
* Revision 7.0 89/11/23 22:13:56 mrose
* 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
#define UNYEAR(y) ((y) < 1900 || (y) > 1999 ? (y) : (y) - 1900)
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
= makewkday (ut
);
tm
-> tm_yday
= tm
-> tm_isdst
= 0;
tm
-> tm_hour
-= ut
-> ut_zone
/ 60, tm
-> tm_min
-= ut
-> ut_zone
% 60;
tm
-> tm_hour
--, tm
-> tm_min
+= 60;
tm
-> tm_hour
++, tm
-> tm_min
-= 60;
/* this ignores odditites in February... */
tm
-> tm_mday
++, tm
-> tm_hour
+= 24;
if (tm
-> tm_mday
> dmsize
[tm
-> tm_mon
]) {
tm
-> tm_mon
++, tm
-> tm_mday
= 1;
tm
-> tm_year
++, tm
-> tm_mon
= 0;
if (tm
-> tm_hour
> 23) {
tm
-> tm_mday
--, tm
-> tm_hour
-= 24;
tm
-> tm_mday
= dmsize
[--tm
-> tm_mon
];
tm
-> tm_year
--, tm
-> tm_mon
= 11;
(((y) % 4) ? 365 : (((y) % 100) ? 366 : (((y) % 400) ? 365 : 366)))
#define YEAR(y) ((y) >= 100 ? (y) : (y) + 1900)
static int makewkday (ut
)
year
= YEAR (ut
-> ut_year
);
d
= 4 + year
+ (year
+ 3) / 4;
d
-= (year
- 1701) / 100;
d
+= (year
- 1601) / 400;
if (dysize (year
) == 366 && mon
> 3)