Created
June 8, 2018 21:07
-
-
Save merlinvn/fdda2aed41234aca894d1385a1f4669a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <chrono> | |
#include <iomanip> | |
#include "ctime" | |
auto convert_to_timepoint(int years, int months, int days) { | |
//perform checks, do division, modulus and stuff... | |
years -= 1900; //epoch | |
std::tm date = {}; | |
date.tm_year = years; | |
date.tm_mon = months; | |
date.tm_mday = days; | |
return std::chrono::system_clock::from_time_t(std::mktime(&date)); | |
} | |
template<typename Clock, typename Duration> | |
std::ostream &operator<<(std::ostream &os, const std::chrono::time_point<Clock, Duration> &timep) { | |
auto converted_timep = Clock::to_time_t(timep); | |
os << std::put_time(std::localtime(&converted_timep), "%Y %b %d %H:%M:%S"); | |
return os; | |
} | |
int total_time = 11000; | |
//1991 Jan 1 | |
//auto start_date= convert_to_timepoint(1991, 0, 100); | |
bool is_first_day_of_month(std::chrono::time_point &point); | |
int main() { | |
// std::cout << start_date; | |
for (int current_time = 0; current_time < total_time; ++current_time) { | |
auto calendar_date= convert_to_timepoint(1991, 0, current_time); | |
if (is_first_day_of_month(calendar_date)) { | |
std::cout << current_time << std::endl; | |
} | |
} | |
return 0; | |
} | |
bool is_first_day_of_month(std::chrono::time_point &point) { | |
return false; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment