gregjesl/brutezone

Add preprocessor definition to filter past times

Closed this issue · 5 comments

Instead of using a target for removing old timezone offsets (like in #21), I'd like to use a preprocessor definition that would filter out old timezone offsets (but leaving the current offset).

It would look something like

static const timezone_offset timezone_database_america_los_angeles[] =
{
#ifndef BRUTEZONE_FUTURE_ONLY
	{0,-2880},
	{9972000,-2520},
	...
	{1552212000,-2520},
	{1572771600,-2880},
#endif
	{1583661600,-2520},
	{1604221200,-2880},
	...
	{2120119200,-2520},
	{2140678800,-2880}
};

timezone_array would also have to be updated based on the number of entries remaining for each time zone.

The advantage of this approach is that it would cooperate better with other build systems (like the EspressIf build chain).

This approach would make #21 irrelevant.

I think it'd have to look something like this:

#ifndef BRUTEZONE_MIN_TIME
#define BRUTEZONE_MIN_TIME 0
#endif

static const time_t timezone_offset_min_time = BRUTEZONE_MIN_TIME;

static const timezone_offset timezone_database_america_los_angeles[] =
{
#if BRUTEZONE_MIN_TIME < 9972000
	{0,-2880},
#endif
#if BRUTEZONE_MIN_TIME < 1552212000
	{9972000,-2520},
#endif
#if BRUTEZONE_MIN_TIME < 1572771600,
	{1552212000,-2520},
#enidf
#if BRUTEZONE_MIN_TIME < ...
	{1572771600,-2880},
#endif
...
};

Then the user could define BRUTEZONE_MIN_TIME to the lowest utc time he cares about.

I just published an iss/24 branch that had my proposed solution but I like your solution better.

The approach for the timezone pointer will have to be similar as well since the length of the timezone array will depend on BRUTEZONE_MIN_TIME.

Closed by #26