Subject Re: isc_encode_timestamp() behaving differently on different databases
Author Iman S. H. Suyoto
--- In firebird-support@yahoogroups.com, "Iman S. H. Suyoto" <ade@...>
wrote:
> /* Set 28 February 2008 00:00:00 */
> tm.tm_sec = tm.tm_min = tm.tm_hour = 0;
> tm.tm_mday = 28;
> tm.tm_mon = 2 - 1;
> tm.tm_year = 2008 - 1900;
>
> if ((lt = mktime(&tm)) == (time_t)-1)
> return 0;

I've found out myself that this is the culprit...

> isc_encode_timestamp(localtime(<), &ts);

... as I didn't know before that isc_encode_timestamp() doesn't honour
the tm_isdst field of struct tm. So, actually, 28 February 2008
01:00:00 got passed instead.

[snip...]

> With copy #2:
>
> > export TZ=whatever
> > ./get_data
> [...snipped...]
> D: (54524, 0)

Actually, I didn't really use 28 February for this case.

In the snipped part of the code I presented, there was a routine call
another function that fetches a timestamp from another field in the
database and returns a struct tm (obtained through
isc_decode_timestamp()). There's another function that converts a
struct tm to ISC_TIMESTAMP using isc_encode_timestamp(), and that
function also uses mktime() to validate the input to that function.

> The get_data binary never got recompiled, i.e. the same binary is used.
> Perhaps isc_encode_timestamp() does something I don't know.

I obtained the source to isc_encode_timestamp() and found out what I
stated above about this function.

Thanks anyway. Sorry for any confusion.