1092
January 1, 1904, 1970, Youtube, international conflicts and curves hands
Unfortunately, long gone topics links, but sometimes extremely entertaining things first hand. Recommend post Anatoly Vorobeya (developer works in "Google»).
In the video format MP4 (MPEG-4 standard), it is possible to record the "time of creation" of any data flow by using a special tag. The value of this tag in the standard: the number of seconds since January 1, 1904, or the so-called «время by age mac », because poppies were the first to use such a timing. Meanwhile, in today's servers are much easier to deal with "time on Unix epoch", namely the number of seconds since January 1, 1970. As a result, in a variety of programs that run on Linux or other of Unix operating systems, there is a piece of code that looks like this:
In the video format MP4 (MPEG-4 standard), it is possible to record the "time of creation" of any data flow by using a special tag. The value of this tag in the standard: the number of seconds since January 1, 1904, or the so-called «время by age mac », because poppies were the first to use such a timing. Meanwhile, in today's servers are much easier to deal with "time on Unix epoch", namely the number of seconds since January 1, 1970. As a result, in a variety of programs that run on Linux or other of Unix operating systems, there is a piece of code that looks like this:
- get the "time now for Unices»;
- Add the difference between Unices and time on the Macintosh - it's kind of a constant;
- the resulting "time now for mac" write to file MP4, that we create.
But there is a little tiny imperceptible poser. Part of the MPEG-4 standard - source libraries that can read and write files to mp4-so reference software in C ++, which everyone can use to borrow or compare with your code. The full title of this part of the standard: ISO / IEC 14496-5. If you're interested, you can download this часть standard free from the official website. And if you look at the source code, you'll see that it uses a different value of this constant, namely 2,082,758 400. This is exactly 86,400 seconds, ie at night, less than the correct value.
How did the creators of the MPEG-4 improperly considered the difference between two dates? Maybe someone manually considered leap years and made a mistake? I do not know. Either way, the wrong value because of its presence in the standard horrible in many libraries for reading and writing formats. Gradually, in recent years the correct value begins to change; if you search in google both numbers, you will see several exact description of the problem in the source code of several projects: "The standard suggests using 2082758400, but the correct value is 2,082,844,800." In other projects, the correct value is worth simply because they counted on the basis of a certain era, and did not use the source code of the standard.
If the library that creates for you MP4-files recorded the wrong value, then what will happen when she wants to record a time of "now"? It will take the correct number of seconds on Unices, add a constant to the day is less than necessary, and thereby give the number of seconds, according to the era of mac which corresponds to the time at night before. I sent a description of the problem and solution developers YouTube's, and I hope that this bug will soon disappear.
Everything in this world is interconnected. Curves hands authors of MPEG-4 leads to conspiracy theories in the Ukrainian conflict. And we live.
Source: habrahabr.ru/post/230571/