cyanskies / another-toml-cpp

MIT License
1 stars 0 forks source link

Time Conversion Functions #10

Open cyanskies opened 1 year ago

cyanskies commented 1 year ago

I'd like to add functions to convert between the datetime types in toml and std::chrono types.

cyanskies commented 1 year ago

Could look at storing time as a std::tm? Will have to look at how other libs handle time.

cyanskies commented 3 months ago

std::tm doesn't have members to store the time offset, but can store all the other data for a localtime and date. So we'd need to store both a std::tm and an extra offset struct.

cyanskies commented 3 months ago

To convert our time types to std::chrono we can follow the following procedure:

The reverse could be done with:

We could also limit it to converting to time_t. Should also look into using std::put_time and std::strftime to do most of the date formatting rather than hand rolling it in to_string_visitor.