| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
/* |
|
2
|
|
|
|
|
|
|
* Copyright (C) 2002 Uwe Ohse, uwe@ohse.de |
|
3
|
|
|
|
|
|
|
* This is free software, licensed under the terms of the GNU General |
|
4
|
|
|
|
|
|
|
* Public License Version 2, of which a copy is stored at: |
|
5
|
|
|
|
|
|
|
* http://www.ohse.de/uwe/licenses/GPL-2 |
|
6
|
|
|
|
|
|
|
* Later versions may or may not apply, see |
|
7
|
|
|
|
|
|
|
* http://www.ohse.de/uwe/licenses/ |
|
8
|
|
|
|
|
|
|
* for information after a newer version has been published. |
|
9
|
|
|
|
|
|
|
*/ |
|
10
|
|
|
|
|
|
|
#include "utcdate2tai.h" |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
/* utc_mktime ... */ |
|
13
|
|
|
|
|
|
|
void |
|
14
|
184
|
|
|
|
|
|
utcdate2tai (struct tai *t, long year, unsigned short mon, unsigned short day, |
|
15
|
|
|
|
|
|
|
unsigned short hour, unsigned short min, unsigned long sec) |
|
16
|
|
|
|
|
|
|
{ |
|
17
|
|
|
|
|
|
|
int days; |
|
18
|
|
|
|
|
|
|
unsigned long ret; |
|
19
|
|
|
|
|
|
|
int schalt; |
|
20
|
|
|
|
|
|
|
static long days_to_month[] = |
|
21
|
|
|
|
|
|
|
{0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365}; |
|
22
|
|
|
|
|
|
|
|
|
23
|
184
|
|
|
|
|
|
ret = 3600 * hour + 60 * min + sec; |
|
24
|
|
|
|
|
|
|
|
|
25
|
184
|
100
|
|
|
|
|
if (year % 4) |
|
26
|
|
|
|
|
|
|
schalt = 0; |
|
27
|
35
|
100
|
|
|
|
|
else if (year % 400 == 0) |
|
28
|
|
|
|
|
|
|
schalt = 1; |
|
29
|
33
|
50
|
|
|
|
|
else if (year % 100 != 0) |
|
30
|
|
|
|
|
|
|
schalt = 1; |
|
31
|
|
|
|
|
|
|
else |
|
32
|
|
|
|
|
|
|
schalt = 0; |
|
33
|
184
|
|
|
|
|
|
days = (year - 1970) * 365; |
|
34
|
184
|
|
|
|
|
|
days += ((year - 1969) / 4); |
|
35
|
184
|
|
|
|
|
|
days -= ((year - 2000) / 100); |
|
36
|
184
|
|
|
|
|
|
days += ((year - 2000) / 400); |
|
37
|
184
|
|
|
|
|
|
days += days_to_month[mon]; |
|
38
|
184
|
|
|
|
|
|
days += day-1; |
|
39
|
184
|
100
|
|
|
|
|
if (schalt && mon > 1) |
|
40
|
|
|
|
|
|
|
days++; |
|
41
|
184
|
|
|
|
|
|
ret += 86400 * days; |
|
42
|
184
|
|
|
|
|
|
tai_unix(t,ret); |
|
43
|
184
|
|
|
|
|
|
} |