1 /* EINA - EFL data type library
2 * Copyright (C) 2008 Cedric Bail
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library 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. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
26 #include "eina_config.h"
27 #include "eina_types.h"
28 #include "eina_hamster.h"
30 /*============================================================================*
32 *============================================================================*/
38 const char *_eina_hamster_time = __TIME__;
39 const char *_eina_hamster_date = __DATE__;
40 static int _eina_hamsters = -1;
46 /*============================================================================*
48 *============================================================================*/
50 /*============================================================================*
52 *============================================================================*/
55 eina_hamster_count(void)
57 if (_eina_hamsters < 0)
59 int hrs = 0, min = 0, sec = 0;
61 int monnum = 0, day = 0, year = 0;
64 fields = sscanf(_eina_hamster_time, "%02d:%02d:%02d", &hrs, &min, &sec);
67 _eina_hamsters = (hrs * 60) + min;
68 fields = sscanf(_eina_hamster_date, "%s %d %d", mon, &day, &year);
88 for (i = 0; i < 12; i++)
90 if (!strcmp(mon, mons[i]))
96 // alloc 60 for mins, 24 for hrs
97 // alloc 1-31 (32) for days, 1-12 (13) for months
98 // use year as-is, for 31 bits (signed) this gives us up to
99 // 3584 years, which is good enough imho. - 1500 years from
102 (day + (monnum * 32) + (13 * 32 * year)) * (24 * 60);
107 // format: [rest - year][0-12 - month][0-31 - day][0-23 - hrs][0-59 - sec]
108 return _eina_hamsters;