我很好奇如何在Ruby中解析这些奇怪的时间戳:
566455139129676
566455199011666
566455199892825
566455259010949
566455319010859
566455335000847
566455336000936
566455336127533
566455347898055
以下是我对这些时间戳格式的了解:
该值是一个64位整数,采用little-endian格式,包含自Julian日以来的微秒数:UTC时区的01 01 00 00:00:00。
对于好奇,这些是Vertica的时间戳的内部表示:https://my.vertica.com/docs/9.0.x/HTML/index.htm#Authoring/AdministratorsGuide/BinaryFilesAppendix/ColumnDefinitions.htm
非常感激任何的帮助。
不确定这里有什么字节序有什么关系。你已经有了一个整数。
那么Epoch是2000年1月1日?基本上你只需要考虑时代之间的差异,1969-12-31和他们的......
epoch = Time.new(2000, 1, 1)
epochOffset = epoch.to_i - Time.at(0).to_i;
ts = Time.at((566455347898055 / 1000000) + epochOffset)
print ts.strftime "%Y-%m-%d %H:%M:%S %z";
> 2017-12-13 04:42:27 +0000