diff --git a/src/markdown.cpp b/src/markdown.cpp index 8df428d..93484ac 100644 --- a/src/markdown.cpp +++ b/src/markdown.cpp @@ -51,11 +51,10 @@ std::optional get_metadata(const std::string &FILE_PATH) { if (toml_time.is_date()) { toml::date d = toml_time.as_date()->get(); - // To convert to a Unix timestamp (time_t): - t.tm_year = d.year - 1900; // tm_year is years since 1900 - t.tm_mon = d.month - 1; // tm_mon is 0-11 + t.tm_year = d.year - 1900; + t.tm_mon = d.month - 1; t.tm_mday = d.day; - t.tm_isdst = -1; + t.tm_isdst = 0; timestamp = mktime(&t); } diff --git a/src/tests/tests.cpp b/src/tests/tests.cpp index 5edeb8d..9c2f20f 100644 --- a/src/tests/tests.cpp +++ b/src/tests/tests.cpp @@ -34,6 +34,8 @@ TEST_CASE("get_metadata function data correctness test") { datetime.tm_year = 2026 - 1900; datetime.tm_mon = 1 - 1; datetime.tm_mday = 1; + datetime.tm_isdst = 0; + time_t expected_date = mktime(&datetime); std::string expected_title = "Example of a blog post"; std::vector expected_tags = {"blog", "test", "lalilulelo"};