write a c++application that extracts a day,month and year and determines whether the date is valid. if the program is given a valid date,an appropriate message is displayed.
#include <chrono>
#include <iostream>
void
displayMessage(std::chrono::year_month_day ymd)
{
    using namespace std;
    using namespace std::chrono;
    if (!ymd.year().ok())
    {
        cout << "Bad year\n";
        return;
    }
    if (!ymd.month().ok())
    {
        cout << "Bad month\n";
        return;
    }
    if (!ymd.ok())
    {
        cout << "Bad day, not 1-" << (ymd.year()/ymd.month()/last).day() << '\n';
        return;
    }
    cout << "Good date!\n";
}
int
main()
{
    using namespace std::literals;
    displayMessage(29d/2/1900);
}
Comments