Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
std::chrono...weekday_last(3) C++ Standard Libarystd::chrono...weekday_last(3)

NAME
       std::chrono::weekday_last::weekday_last	     -	    std::chrono::week-
       day_last::weekday_last

Synopsis
	  explicit constexpr weekday_last( const  std::chrono::weekday&	 wd  )
       (since C++20)
	  noexcept;

	  Constructs a weekday_last object storing the weekday wd.

Notes
	  A  more convenient way to construct a	weekday_last is	with weekday's
       operator[],
	  i.e.,	wd[std::chrono::last].

Example
       // Run this code

	#include <chrono>
	#include <iostream>
	using namespace	std::chrono;

	int main() {
	    const year_month_day ymd { floor<days>(system_clock::now())	};
	    const weekday_last wdl { Sunday[last] }; //	A  last	 Sunday	 of  a
       month
	    const year_month_day last_sun { ymd.year() / ymd.month() / wdl };

	    std::cout << "The last Sunday of current month falls on "
		      << (int)last_sun.year() << '/'
		      << (unsigned)last_sun.month() << '/'
		      << (unsigned)last_sun.day() << '\n';
	}

Possible output:
	The last Sunday	of current month falls on 2021/9/26

http://cppreference.com		  2022.07.31	 std::chrono...weekday_last(3)

Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=std::chrono::weekday_last::weekday_last&sektion=3&manpath=FreeBSD+Ports+15.0>

home | help