Skip to content

Instantly share code, notes, and snippets.

@zlsun
Created January 9, 2016 07:26
Show Gist options
  • Select an option

  • Save zlsun/f515af6336614747e1e6 to your computer and use it in GitHub Desktop.

Select an option

Save zlsun/f515af6336614747e1e6 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <iomanip>
#include "date.h"
using namespace std;
using namespace date;
using namespace std::chrono;
int main(int argc, char *argv[])
{
auto y = 2016_y;
for (auto m = 1; m <= 12; ++m) {
auto b = y / m / 1;
auto e = b + months(1);
cout << string(8, ' ') << b.month() << endl;
const int N = 5 * 7;
int M[N] = {0};
int i = unsigned(weekday(b));
days ds = day_point(e) - day_point(b);
for (auto d = 1; d <= ds.count(); ++d) {
M[i++] = d;
}
for (int j = 0; j < N; ++j) {
cout << setw(2);
if (M[j]) cout << M[j];
else cout << " ";
cout << ((j + 1) % 7 ? ' ' : '\n');
}
cout << endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment