Created
August 6, 2018 19:10
-
-
Save meshula/8ec268495990b3d0aad81aea9d2934c8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int main() | |
{ | |
uint64_t test_hours = 2; | |
uint64_t test_minutes = 43; | |
uint64_t test_seconds = 32; | |
uint64_t test_frames = 3; | |
std::cout << "EXPECTED: " << test_hours << ":" << test_minutes << ":" << test_seconds << ":" << test_frames << std::endl; | |
double hr_ms = test_hours * 60 * 60 * 1000; | |
double mi_ms = test_minutes * 60 * 1000; | |
double s_ms = test_seconds * 1000; | |
double fr_ms = 1000 * test_frames / 24.; | |
double time = hr_ms + mi_ms + s_ms + fr_ms; | |
uint64_t ut = static_cast<uint64_t>(time); | |
auto ch_time = std::chrono::milliseconds(ut); | |
int hours = std::chrono::floor<std::chrono::hours>(ch_time).count(); | |
int minutes = std::chrono::floor<std::chrono::minutes>(ch_time).count(); | |
int seconds = std::chrono::floor<std::chrono::seconds>(ch_time).count(); | |
int milliseconds = std::chrono::floor<std::chrono::milliseconds>(ch_time).count(); | |
minutes -= hours * 60; | |
seconds -= ((hours * 60) + minutes) * 60; | |
milliseconds -= ((((hours * 60) + minutes) * 60) + seconds) * 1000; | |
double frames = std::floor(static_cast<double>(milliseconds) * 24. / 1000.); | |
int frames_i = static_cast<int>(frames); | |
std::cout << "ACTUAL: " << hours << ":" << minutes << ":" << seconds << ":" << frames_i << std::endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment