Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Apache Thrift How Should Date Objects Be Represented

Tags:

People also ask

What is Thrift protocol?

Thrift is an interface definition language and binary communication protocol used for defining and creating services for numerous programming languages. It was developed at Facebook for "scalable cross-language services development" and as of 2020 is an open source project in the Apache Software Foundation.

What is a Thrift object?

Thrift structs define a common object – they are essentially equivalent to classes in OOP languages, but without inheritance. A struct has a set of strongly typed fields, each with a unique name identifier. Fields may have various annotations (numeric field IDs, optional default values, etc.)

What is IDL Thrift?

The Thrift interface definition language (IDL) allows for the definition of Thrift Types. A Thrift IDL file is processed by the Thrift code generator to produce code for the various target languages to support the defined structs and services in the IDL file.


In the Thrift IDL there isn't a Date type. What's the best cross language mechanism to represent a date object. I think there are 2 ideal candidates but I'd love to hear other ideas.

  1. String - in each language you could use something like strftime to convert the date back.
  2. i32 - Time since epoch can be converted back.

I'm sure there are other things to think about besides conversion. Hoping people out there have some good feedback.