File: caltime_utc.c

package info (click to toggle)
publicfile 0.52-13
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 896 kB
  • sloc: ansic: 3,903; makefile: 468; sh: 296
file content (35 lines) | stat: -rw-r--r-- 589 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include "tai.h"
#include "leapsecs.h"
#include "caldate.h"
#include "caltime.h"

/* XXX: breaks tai encapsulation */

void caltime_utc(ct,t,pwday,pyday)
struct caltime *ct;
struct tai *t;
int *pwday;
int *pyday;
{
  struct tai t2 = *t;
  uint64 u;
  int leap;
  long s;

  /* XXX: check for overfow? */

  leap = leapsecs_sub(&t2);
  u = t2.x;

  u += 58486;
  s = u % 86400ULL;

  ct->second = (s % 60) + leap; s /= 60;
  ct->minute = s % 60; s /= 60;
  ct->hour = s;

  u /= 86400ULL;
  caldate_frommjd(&ct->date,/*XXX*/(long) (u - 53375995543064ULL),pwday,pyday);

  ct->offset = 0;
}