| 41 | } // namespace |
| 42 | |
| 43 | time_t internalTimegm(std::tm const* t) { |
| 44 | int year = t->tm_year + 1900; |
| 45 | int month = t->tm_mon; |
| 46 | if (month > 11) { |
| 47 | year += month / 12; |
| 48 | month %= 12; |
| 49 | } else if (month < 0) { |
| 50 | const int years_diff = (-month + 11) / 12; |
| 51 | year -= years_diff; |
| 52 | month += 12 * years_diff; |
| 53 | } |
| 54 | month++; |
| 55 | const int day = t->tm_mday; |
| 56 | const int day_of_year = daysFrom1jan(year, month, day); |
| 57 | const time_t days_since_epoch = |
| 58 | static_cast<time_t>(daysFrom1970(year) + day_of_year); |
| 59 | |
| 60 | const time_t seconds_in_day = static_cast<time_t>(3600 * 24); |
| 61 | const time_t result = |
| 62 | seconds_in_day * days_since_epoch + |
| 63 | static_cast<time_t>(3600 * t->tm_hour + 60 * t->tm_min + t->tm_sec); |
| 64 | |
| 65 | return result; |
| 66 | } |
| 67 | |
| 68 | } // namespace CesiumAsync |
no test coverage detected