|
|
1.1 root 1: /*
2: Copyright (C) 1996-1997 Id Software, Inc.
3:
4: This program is free software; you can redistribute it and/or
5: modify it under the terms of the GNU General Public License
6: as published by the Free Software Foundation; either version 2
7: of the License, or (at your option) any later version.
8:
9: This program is distributed in the hope that it will be useful,
10: but WITHOUT ANY WARRANTY; without even the implied warranty of
11: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12:
13: See the included (GNU.txt) GNU General Public License for more details.
14:
15: You should have received a copy of the GNU General Public License
16: along with this program; if not, write to the Free Software
17: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18:
19: */
20: #include <stdlib.h>
21: #include <string.h>
22:
23: #include <quakedef.h>
24:
25: // char *date = "Oct 24 1996";
26: // char *time = "13:22:52";
27: char *date = __DATE__ ;
28: char *time = __TIME__ ;
29:
30: char *mon[12] =
31: { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
32: char mond[12] =
33: { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
34:
35: // returns days since Oct 24 1996
36: int build_number( void )
37: {
38: int m = 0;
39: int d = 0;
40: int y = 0;
41: int hr, min;
42: static int b = 0;
43:
44: if (b != 0)
45: return b;
46:
47: for (m = 0; m < 11; m++)
48: {
49: if (_strnicmp( &date[0], mon[m], 3 ) == 0)
50: break;
51: d += mond[m];
52: }
53:
54: d += atoi( &date[4] ) - 1;
55:
56: y = atoi( &date[7] ) - 1900;
57:
58: b = d + (int)((y - 1) * 365.25);
59:
60: if (((y % 4) == 0) && m > 1)
61: {
62: b += 1;
63: }
64:
65: b -= 34995; // Oct 24 1996
66:
67: hr = (time[0] - '0') * 10 + (time[1] - '0');
68: min = (time[3] - '0') * 10 + (time[4] - '0');
69: // sec = (time[6] - '0') * 10 + (time[7] - '0');
70:
71: b *= 60*24;
72: b += hr * 60 + min;
73:
74: return b;
75: }
76:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.