@portfast

News & views, serious business.

Tuesday 31 March 2015 - Time is hard

Taking a side-step from the usual internet related topics, I'm going to share my experience of parsing the TDT in a DVB stream. I feel it warrants a wider audience due to the unforseen complexity of this particular piece of work.

The TDT is a stream in the multiplexes that transport digital TV, via satellite or terrestrial, the format is the same. The function of this particular stream (always within PID 0x14) is to carry the date and time.

The full specification of this field is laid out in EN 300 468, along with many other parts of the DVB stream. To start with, you have 16 bits which carry the date in Modified Julian Date format. It dates back to 1957 and according to Wikipedia was contrived to record the orbit of Sputnik on a 36 bit IBM mainframe, but is not, for me, the strangest bit of the spec.

The part which for me defies all explanation is why they have used binary coded decimal for the hours, minutes and seconds.

Here is a bit of C that parses it into normal Unix seconds-since-1970.

Knowing the time is a fairly fundamental part of most TV functions, so just spare a minute to think of the poor soul who will have thought "This won't take long!", before dropping their sandwich and having a little cry, just so your TV knows what time it is.


All prices are exclusive of VAT.
Portfast Ltd :: Registered in England #6061075, 7 Carter Knowle Road, Sheffield, S7 2DW