CNtpTime::CNtpTime( const SYSTEMTIME & st ) { // Currently this function only operates correctly in // the 1900 - 2036 primary epoch defined by NTP long JD = GetJulianDay( st.wYear, st.wMonth, st.wDay ); JD -= JAN_1ST_1900; ASSERT( JD >= 0 ); // NTP only supports dates greater than 1900 unsigned __int64 Seconds = JD; Seconds = ( Seconds * 24 ) + st.wHour; Seconds = ( Seconds * 60 ) + st.wMinute; Seconds = ( Seconds * 60 ) + st.wSecond; ASSERT( Seconds <= 0xffffffff ); // NTP only supports up to 2036 m_Time = ( Seconds << 32 ) + MsToNtpFraction( st.wMilliseconds ); }
void FDateTime::GetDate( int32& OutYear, int32& OutMonth, int32& OutDay ) const { // Based on FORTRAN code in: // Fliegel, H. F. and van Flandern, T. C., // Communications of the ACM, Vol. 11, No. 10 (October 1968). int32 i, j, k, l, n; l = FMath::FloorToInt(GetJulianDay() + 0.5) + 68569; n = 4 * l / 146097; l = l - (146097 * n + 3) / 4; i = 4000 * (l + 1) / 1461001; l = l - 1461 * i / 4 + 31; j = 80 * l / 2447; k = l - 2447 * j / 80; l = j / 11; j = j + 2 - 12 * l; i = 100 * (n - 49) + i + l; OutYear = i; OutMonth = j; OutDay = k; }