seznam / fastrpc

FastRPC library
http://seznam.github.io/frpc
GNU Lesser General Public License v2.1
46 stars 46 forks source link

pool.DateTime(time_t, tz) and UTCTime(time_t) are wrong #81

Open volca02 opened 4 years ago

volca02 commented 4 years ago

The root cause is that the constructor of DateTime(time_t, timezone) will ignore the timezone altogether, so the component part of the time specification will be offset.

#include <iostream>

#include <frpcpool.h>
#include <frpcdatetime.h>

int main() {
    FRPC::Pool_t pool;

    auto &dt = pool.UTCTime(0);

    std::cout << dt.isoFormat() << std::endl;

    return 0;
}

outputs:

19700101T01:00:00+0000

which should be

19700101T00:00:00+0000

or

19700101T01:00:00+0100