mirror of
https://github.com/HowardHinnant/date.git
synced 2025-08-05 21:54:27 +02:00
Updated Boost datetime Examples Translated (markdown)
@@ -322,26 +322,24 @@ main()
|
||||
```
|
||||
<a name="Month_Adding"></a>
|
||||
### Month Adding
|
||||
```c++
|
||||
#include "tz.h"
|
||||
#include <iostream>
|
||||
|
||||
#include "date.h"
|
||||
#include "tz.h"
|
||||
#include <iostream>
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace std::chrono;
|
||||
using namespace date;
|
||||
auto zone = current_zone();
|
||||
auto d = year_month_day{floor<days>(
|
||||
zone->to_local(system_clock::now()))};
|
||||
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';
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace std::chrono;
|
||||
using namespace date;
|
||||
auto d = year_month_day{floor<days>(make_zoned(current_zone(),
|
||||
system_clock::now()).get_local_time())};
|
||||
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>
|
||||
### Time Math
|
||||
|
||||
|
Reference in New Issue
Block a user