mirror of
https://github.com/HowardHinnant/date.git
synced 2025-08-06 14:14:27 +02:00
Updated Boost datetime Examples Translated (markdown)
@@ -322,26 +322,24 @@ main()
|
|||||||
```
|
```
|
||||||
<a name="Month_Adding"></a>
|
<a name="Month_Adding"></a>
|
||||||
### Month Adding
|
### Month Adding
|
||||||
|
```c++
|
||||||
|
#include "tz.h"
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
#include "date.h"
|
int
|
||||||
#include "tz.h"
|
main()
|
||||||
#include <iostream>
|
{
|
||||||
|
using namespace std::chrono;
|
||||||
int
|
using namespace date;
|
||||||
main()
|
auto d = year_month_day{floor<days>(make_zoned(current_zone(),
|
||||||
{
|
system_clock::now()).get_local_time())};
|
||||||
using namespace std::chrono;
|
auto d2 = d + months{1};
|
||||||
using namespace date;
|
if (!d2.ok())
|
||||||
auto zone = current_zone();
|
d2 = d2.year()/d2.month()/last; // boost snaps to last
|
||||||
auto d = year_month_day{floor<days>(
|
std::cout << "Today is: " << d << ".\n"
|
||||||
zone->to_local(system_clock::now()))};
|
<< "One month from today will be: " << d2 << '\n';
|
||||||
auto d2 = d + months{1};
|
}
|
||||||
if (!d2.ok())
|
```
|
||||||
d2 = d2.year()/d2.month()/last; // boost snaps to last
|
|
||||||
std::cout << "Today is: " << d << ".\n"
|
|
||||||
<< "One month from today will be: " << d2 << '\n';
|
|
||||||
}
|
|
||||||
|
|
||||||
<a name="Time_Math"></a>
|
<a name="Time_Math"></a>
|
||||||
### Time Math
|
### Time Math
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user