diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/chronology.cpp | 12 | ||||
-rw-r--r-- | lib/chronology.h | 2 | ||||
-rw-r--r-- | lib/maths.h | 4 |
3 files changed, 18 insertions, 0 deletions
diff --git a/lib/chronology.cpp b/lib/chronology.cpp new file mode 100644 index 0000000..8707bba --- /dev/null +++ b/lib/chronology.cpp @@ -0,0 +1,12 @@ +#include "chronology.h" + +time_t +operator""_time_t(const char * iso, size_t) +{ + struct tm tm {}; + + if (const auto end = strptime(iso, "%FT%T", &tm); !end || *end) { + throw std::invalid_argument("Invalid date"); + } + return mktime(&tm); +} diff --git a/lib/chronology.h b/lib/chronology.h index 1980116..688a1f7 100644 --- a/lib/chronology.h +++ b/lib/chronology.h @@ -1,5 +1,7 @@ #pragma once #include <chrono> +#include <ctime> using TickDuration = std::chrono::duration<float, std::chrono::seconds::period>; +time_t operator""_time_t(const char * iso, size_t); diff --git a/lib/maths.h b/lib/maths.h index 018ef0e..3127d3c 100644 --- a/lib/maths.h +++ b/lib/maths.h @@ -42,6 +42,10 @@ constexpr auto half_pi {glm::half_pi<float>()}; constexpr auto quarter_pi {half_pi / 2}; constexpr auto pi {glm::pi<float>()}; constexpr auto two_pi {glm::two_pi<float>()}; +constexpr auto degreesToRads = pi / 180.F; + +constexpr auto earthMeanRadius = 6371.01F; // In km +constexpr auto astronomicalUnit = 149597890.F; // In km template<glm::length_t D> constexpr inline GlobalPosition<D> |