Which is the correct way to use the conversion from imploded to exploded times with apr in localtime?
I have set up a small example which behaves oddly, so I must be doing something wrong.
Suppose we have an apr time stamp 'a' (microseconds from the epoch as a long integer), if we calculate the exploded time for it (that is the date with it fields, year, month, day, hour, ....), let's call it 'b' and then the imploded time from this 'b', I expect it to match 'a'.
When working in gmt this works fine. I have tested it with this code:
#include <apr_time.h>
#include <iostream>
int main(int argc, char ** argv)
{
apr_time_t a = apr_time_now();
apr_time_exp_t b;
apr_time_exp_gmt(&b, a);
apr_time_t c;
apr_time_exp_gmt_get(&c, &b);
std::cout << a << " " << c << std::endl;
std::cout << (a == c) << std::endl;
}
Getting the output:
1429598910304919 1429598910304919
1
So far so good. However when doing calculations in local time it doesn't match. Let's take the same example as above but with letters x, y and z.
#include <apr_time.h>
#include <iostream>
int main(int argc, char ** argv)
{
apr_time_t x = apr_time_now();
apr_time_exp_t y;
apr_time_exp_lt(&y, a);
apr_time_t z;
apr_time_exp_get(&z, &y);
std::cout << x << " " << z << std::endl;
std::cout << (x == z) << std::endl;
}
The output I get is:
1429598910320544 1429606110304919
0
I expected that applying a function and its inverse to a value will return me the same value, so what it is that I'm doing wrong?