mirror of
https://github.com/HowardHinnant/date.git
synced 2025-08-05 05:34:27 +02:00
Updated Examples and Recipes (markdown)
@@ -1356,18 +1356,18 @@ First the code, and then a detailed explanation:
|
|||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
// Output month and year title
|
// Output month and year title
|
||||||
os << left << setw(21) << format(os.getloc(), " %B %Y", sys_days{ym/1}) << right;
|
os << left << setw(21) << format(os.getloc(), " %B %Y", ym) << right;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
{
|
{
|
||||||
// Output weekday names title
|
// Output weekday names title
|
||||||
auto sd = sys_days{ym/firstdow[1]};
|
auto wd = first dow;
|
||||||
for (auto const esd = sd + weeks{1}; sd < esd; sd += days{1})
|
do
|
||||||
{
|
{
|
||||||
auto d = format(os.getloc(), "%a", sd);
|
auto d = format(os.getloc(), "%a", wd);
|
||||||
d.resize(2);
|
d.resize(2);
|
||||||
os << ' ' << d;
|
os << ' ' << d;
|
||||||
}
|
} while (++wd != firstdow);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 2:
|
case 2:
|
||||||
@@ -1378,7 +1378,7 @@ First the code, and then a detailed explanation:
|
|||||||
auto d = 1_d;
|
auto d = 1_d;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
os << setw(3) << unsigned(d);
|
os << format(" %e", d);
|
||||||
++d;
|
++d;
|
||||||
} while (++wd != firstdow);
|
} while (++wd != firstdow);
|
||||||
break;
|
break;
|
||||||
@@ -1399,7 +1399,7 @@ First the code, and then a detailed explanation:
|
|||||||
auto wd = firstdow;
|
auto wd = firstdow;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
os << setw(3) << unsigned(d);
|
os << format(" %e", d);
|
||||||
} while (++wd != firstdow && ++d <= e);
|
} while (++wd != firstdow && ++d <= e);
|
||||||
// Append row with spaces if the week did not complete
|
// Append row with spaces if the week did not complete
|
||||||
os << string(static_cast<unsigned>((firstdow-wd).count())*3, ' ');
|
os << string(static_cast<unsigned>((firstdow-wd).count())*3, ' ');
|
||||||
|
Reference in New Issue
Block a user