2 #include <boost/date_time/gregorian/gregorian.hpp> 11 namespace greg = boost::gregorian;
16 const uint8_t num_months_horizontally,
20 using fn::operators::operator%;
25 date = date + greg::date_duration{ 1 };
31 return std::make_pair(d.month(), d.week_number());
37 const auto left_pad_amt =
38 size_t(3 * ((wk_dates.front().day_of_week() + 7 - 1) % 7));
40 return { wk_dates.front().month(),
41 wk_dates %
fn::foldl(std::string(left_pad_amt,
' '),
42 [](std::string ret_wk,
const date_t& d)
44 return std::move(ret_wk)
45 + (d.day() < 10 ?
" " :
" ")
46 + std::to_string(d.day());
56 static const std::array<std::string, 12> s_month_names{
57 "Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec" };
59 for(
int row = -2; row < 6; row++) {
60 for(
const auto& mo : group) {
61 ostr << std::setiosflags(std::ios::left)
63 << ( row == -2 ?
" " + s_month_names.at(mo.front().first - 1u)
64 : row == -1 ?
" Mo Tu We Th Fr Sa Su" 65 :
size_t(row) < mo.size() ? mo[row].second
impl::group_adjacent_by< F > group_adjacent_by(F key_fn)
Group adjacent elements.
impl::group_adjacent_by< impl::chunker > in_groups_of(size_t n)
Group adjacent elements into chunks of specified size.
impl::foldl< Result, Op > foldl(Result init, Op binary_op)
Range-based version of c++20 (copy-free) std::accumulate
LINQ -like library of higher-order functions for data manipulation.
Return fn::end_seq() from input-range generator function to signal end-of-inputs.
impl::seq< impl::catch_end< NullaryInvokable > > seq(NullaryInvokable gen_fn)
Adapt a generator function as InputRange.
static void MakeCalendar(const uint16_t year, const uint8_t num_months_horizontally, std::ostream &ostr)
std::vector< date_t > dates_t
impl::for_each< F > for_each(F fn)