Skip to content

Instantly share code, notes, and snippets.

@ifknot
Last active October 17, 2020 15:44
Show Gist options
  • Save ifknot/1c33a1efbfd5b36168d472ea38dba3cd to your computer and use it in GitHub Desktop.
Save ifknot/1c33a1efbfd5b36168d472ea38dba3cd to your computer and use it in GitHub Desktop.
r-ish date type
#pragma once
#include <string>
#include <ctime>
#include <ostream>
namespace R {
/**
* An R-ish calender date type
* This is the type to use if you have only dates, but no times, in your data.
* Default format is "%Y-%m-%d" e.g. 2020 - 09 - 30
* functions: as_dates, diffdates, +, -, etc
*/
struct r_date {
std::tm tm{};
std::string format{};
};
}
std::ostream& operator<<(std::ostream& os, const R::r_date& date);
bool operator == (const R::r_date& lhs, const R::r_date& rhs);
bool operator < (const R::r_date& lhs, const R::r_date& rhs);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment