A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://en.cppreference.com/w/cpp/../cpp/../cpp/algorithm/../chrono/year_month/operator_arith_2.html below:

std::chrono::operator+, std::chrono::operator- (std::chrono::year_month) - cppreference.com

1,2) Adds dy.count() years to ym.

3,4) Adds dm.count() months to ym.

5) Subtracts dy.count() years from ym.

6) Subtracts dm.count() months from ym.

7) Returns the difference in months between the two time points represented by ym1 and ym2.

For durations that are convertible to both std::chrono::years and std::chrono::months, the years overloads (1,2,5) are preferred if the call would otherwise be ambiguous.

[edit] Return value

3,4) A year_month value z such that z - ym == dm and z.ok() == true.

5) ym + -dy

6) ym + -dm

7)
ym1.year() - ym2.year() + std::chrono::months(int(unsigned(ym1.month())) -
int(unsigned(ym2.month())))
[edit] Notes

The result of subtracting two year_month values is a duration of type std::chrono::months. This duration unit represents the length of the average Gregorian month (30.436875 days), and the resulting duration bears no relationship to the actual number of days in the time period at issue. For example, the result of 2017y/3 - 2017y/2 is std::chrono::months(1), even though February 2017 only contains 28 days.

[edit] Example [edit] See also

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4