Skip to content

mguludag/chrono_parse

Folders and files

NameName
Last commit message
Last commit date

Latest commit

24b4c2c · Apr 25, 2023

History

25 Commits
Apr 25, 2023
Apr 15, 2023
Apr 25, 2023

Repository files navigation

get_time

parse date and times with {fmt} style intostd::chrono::time_point {WIP}

#include "get_time.hpp"

// {fmt} for printing
#include <fmt/chrono.h>
#include <fmt/format.h>

int main() {
    const auto chrono_time = mgutility::get_time("{:%FT%T.%f%z}", "2023-04-16T00:05:23.999+0100");

    fmt::print("{:%F %T}\n", chrono_time); // prints 2023-04-15 23:05:23.999000000 ({fmt} trunk version)
}

Notes

  • Currently not supported all format specifiers (at least ISO-8601 capable now)
  • Requires C++17 and upper
  • Performance is ~20x faster than std::get_time and ~70x faster than std::get_time + std::mktime.

P2FgpMZs9Cv9pq8vk8G-es_q9G4