On Thu, 30 Sep 2021, Sven Schreiber wrote:
Am 30.09.2021 um 16:50 schrieb Riccardo (Jack) Lucchetti:
> On Thu, 30 Sep 2021, Sven Schreiber wrote:
>> Am 30.09.2021 um 16:39 schrieb Riccardo (Jack) Lucchetti:
>>> Indeed, this looks like a strptime bug. For example:
>>
>> So you mean gretl's strptime, or some other underlying library's
>> strptime?
>
> I mean gretl's implementation. Although this is weird, since our own
> strpitime is basically just a wrapper around the corresponding C
> function. If you want to take a look, the function you want is at line
> 8510 of lib/src/geneval.c.
Don't know about the code there, but in principle it feels like an
off-by-one bug, no?
I think I have an Idea of what's happening. Here's a bare-bone
replication of what happens "inside" (tested on Linux, I have no idea if
it evenm works on windows).
<C>
#define _XOPEN_SOURCE
#include<stdio.h>
#include<time.h>
int main()
{
struct tm tm = {0};
char a[] = "1984-01-01";
char b[128];
char fmt[] = "%Y-%m-%d";
char *s;
s = strptime(a, fmt, &tm);
if (s != NULL) {
time_t t = mktime(&tm);
strftime(b, 128, "%Y-%m-%d %H:%M", gmtime(&t));
printf("%s\n", b);
strftime(b, 128, "%Y-%m-%d %H:%M", localtime(&t));
printf("%s\n", b);
} else {
puts("strptime failed!\n");
}
return 0;
}
</C>
The problem may have to do with time zones. I can't investigate further,
thow, I've got to run, sorry.
-------------------------------------------------------
Riccardo (Jack) Lucchetti
Dipartimento di Scienze Economiche e Sociali (DiSES)
Università Politecnica delle Marche
(formerly known as Università di Ancona)
r.lucchetti(a)univpm.it
http://www2.econ.univpm.it/servizi/hpp/lucchetti
-------------------------------------------------------