MCPcopy Create free account
hub / github.com/MediaArea/MediaInfoLib / Date_MJD

Function Date_MJD

Source/MediaInfo/TimeCode.cpp:893–912  ·  view source on GitHub ↗

--------------------------------------------------------------------------- Modified Julian Date

Source from the content-addressed store, hash-verified

891//---------------------------------------------------------------------------
892//Modified Julian Date
893std::string Date_MJD(uint16_t Date_)
894{
895 //Calculating
896 double Date = Date_;
897 if ((Date_ & 0x8000) == 0)
898 Date += 0x10000; // adjust the MJD to support dates beyond the 16 bit rollover in 2038
899 int Y2 = (int)((Date - 15078.2) / 365.25);
900 int M2 = (int)(((Date - 14956.1) - ((int)(Y2 * 365.25))) / 30.6001);
901 int D = (int)(Date - 14956 - ((int)(Y2 * 365.25)) - ((int)(M2 * 30.6001)));
902 int K = 0;
903 if (M2 == 14 || M2 == 15)
904 K = 1;
905 int Y = Y2 + K;
906 int M = M2 - 1 - K * 12;
907
908 //Formatting
909 return to_string(1900 + Y) + '-'
910 + (M < 10 ? "0" : "") + to_string(M) + '-'
911 + (D < 10 ? "0" : "") + to_string(D);
912}
913
914//---------------------------------------------------------------------------
915//Form: HHMMSS, BCD

Callers 4

Descriptor_58Method · 0.85
Table_4EMethod · 0.85
Table_70Method · 0.85
Table_73Method · 0.85

Calls 1

to_stringFunction · 0.85

Tested by

no test coverage detected