This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
yap-6.3/os/libtai/caltime_utc.c
Vitor Santos Costa 9cfd4d8d8b move package/PLStream to os
modify Makefiles accordingly
define __unix__ on Unix like clones (OSX, AIX, etc).
2011-09-04 19:42:33 +02:00

32 lines
582 B
C

#include "tai.h"
#include "leapsecs.h"
#include "caldate.h"
#include "caltime.h"
/* XXX: breaks tai encapsulation */
void caltime_utc(struct caltime *ct, struct tai *t, int *pwday, int *pyday)
{
struct tai t2 = *t;
uint64_t u;
int leap;
long s;
/* XXX: check for overfow? */
leap = leapsecs_sub(&t2);
u = t2.x;
u += 58486;
s = (long)(u % ULL(86400));
ct->second = (s % 60) + leap; s /= 60;
ct->minute = s % 60; s /= 60;
ct->hour = s;
u /= ULL(86400);
caldate_frommjd(&ct->date, (int64_t)u - LL(53375995543064), pwday, pyday);
ct->offset = 0;
}