Trial Offer
Trial Offer

Reputation: 129

Incorrect epoch date in node.js using thrift

I seem to be getting a different epoch date value in node.js for a thrift object than what is stored in the mongo database and returned by the service

Thrift definition file (thrift v0.9.0), I have

struct Profile {
    ...
    4: i64 createDate,
    5: i64 lastUpdateDate

Mongo record

"createdTimestamp" : NumberLong("1366334385361"),
"lastUpdatedTimestamp" : NumberLong("1366334385361")

Node reports

createDate: 534785233,
lastUpdateDate: 534785233

The generated node thrift client seems to have I64 referenced.

if (this.createDate !== null && this.createDate !== undefined) {
    output.writeFieldBegin('createDate', Thrift.Type.I64, 14);
    output.writeI64(this.createDate);
    output.writeFieldEnd();
}

I appreciate any insight that comes along.

Thanks

Upvotes: 1

Views: 461

Answers (1)

user568109
user568109

Reputation: 48003

Binary representation for given numbers are :

1366334385361  ->  10011111000011111111000000010110011010001
534785233      ->  00000000000011111111000000010110011010001

i.e. if you take lower 32 bits of 1366334385361, you get 534785233. So somewhere in your program or package you are using, it is getting converted/truncated into 32 bit integer e.g. int(1366334385361)

Upvotes: 1

Related Questions