On Thu, 25 Apr 2019, Artur Tarassow wrote:
I am a bit puzzled by the following example where I first convert a
date
string into a timestamp before converting int back into a date string.
However, instead of getting returned "2005:01", gretl returns
"2004:12".
It seems that the strptime() function does some weird thing, as can be
checked here:
https://www.epochconverter.com/
But maybe I miss something fundamental here.
This is with latest git on ubuntu 19.04.
<hansl>
string init_obs = "01/2005"
scalar tstamp = strptime(init_obs, "%m/%Y")
eval strftime(tstamp, "%Y:%m") # returns '2004:12'
</hansl>
I see what you mean. Apparently that's how strptime and strftime
work: if you just specify January 2005 on input strptime gives the
epoch value for midnight of December 2004/January 2005, which seems
to belong to 2004 by convention (of strftime, at least).
If you give, e.g., "01/01/2005" for input as "%d/%m/%Y" you'll
get
"2005:1" for output via strftime(tstamp, "%Y:%m").
Allin