2016-03-18 24 views
3

我正在做一個實時信號處理:處理子秒精確UTC時間算術的閏秒

我的輸入是帶有時間戳的標籤。 我的輸出在UTC

我需要補償處理延遲標記有時間戳的估計,因此在樣本N我會輸出採樣N-KK的估計是我的處理延遲。

時間補償必須閏秒意識到。即具有10ms延遲:

INPUT TS = 20150701T000000.000000 
OUTPUT TS = 20150630T235960.990000 

我認爲struct tm作爲時間戳,利用第61秒。

但我無法找到(struct tm <→TAI)翻譯功能。

任何建議表示讚賞。

回答

0

Howard Hinnant's timezone library(自由,開放源碼,跨平臺的,C++ 11)將處理這樣的:

#include "tz.h" 
#include <iostream> 
#include <sstream> 

int 
main() 
{ 
    using namespace std; 
    using namespace std::chrono; 
    using namespace date; 
    istringstream in{"20150701T000000.000000"}; 
    utc_time<microseconds> ts; 
    in >> parse("%Y%m%dT%H%M%S", ts); 
    ts -= 10ms; 
    std::cout << format("%Y%m%dT%H%M%S", ts) << '\n'; 
} 

輸出:

20150630T235960.990000