File: basic_md_get_yday.c

package info (click to toggle)
dateutils 0.4.11-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,228 kB
  • sloc: ansic: 22,598; makefile: 1,771; yacc: 202; sh: 168; lex: 108
file content (64 lines) | stat: -rw-r--r-- 1,066 bytes parent folder | download | duplicates (6)
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#if defined HAVE_CONFIG_H
# include "config.h"
#endif	/* HAVE_CONFIG_H */
#include "strops.h"
#include "strops.c"
#include "token.h"
#include "token.c"
#include "date-core.h"
#include "date-core.c"
#include "dt-locale.h"
#include "dt-locale.c"

static unsigned int
super(unsigned int res)
{
	for (int y = 1917; y < 2299; y++) {
		for (int m = 1; m <= 12; m++) {
			for (int d = 0; d < 32; d++) {
				unsigned int yd;
				yd = __md_get_yday(y, m, d);
				res += y * m * yd + d;
			}
		}
	}
	return res;
}

#if 0
static unsigned int
hyper(unsigned int hyper)
{
	dt_ymd_t x;
	for (int y = 1917; y < 4096; y++) {
		for (int m = 1; m <= 12; m++) {
			for (int d = 0; d < 32; d++) {
				unsigned int yd;
				x.y = y;
				x.m = m;
				x.d = d;
				yd = __ymd_get_yday(x);
				hyper += yd;
			}
		}
	}
	return hyper;
}
#endif

int
main(void)
{
	unsigned int supersum = 0;

	for (size_t i = 0; i < 4096; i++) {
		supersum += super(supersum);
	}
	printf("super %u\n", supersum);
	if (supersum != 2780223808U) {
		return 1;
	}
	return 0;
}

/* basic_md_get_yday.c ends here */