Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::chrono::weekday_last::weekday_last

      From cppreference.com
      <cpp‎ |chrono‎ |weekday last
       
       
      Date and time library
       
       
      constexprexplicit weekday_last(conststd::chrono::weekday& wd)noexcept;
      (since C++20)

      Constructs aweekday_last object storing theweekdaywd.

      [edit]Notes

      A more convenient way to construct aweekday_last is withweekday'soperator[], i.e.,wd[std::chrono::last].

      [edit]Example

      Run this code
      #include <chrono>#include <iostream>usingnamespace 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 monthconst 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
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/chrono/weekday_last/weekday_last&oldid=161682"

      [8]ページ先頭

      ©2009-2026 Movatter.jp