Page 1 of 1

it shows 2022/6/20, 2021/6/20 and 2023/6/20, but I want the date to be 2022/06/20, 2021,06/20, 2023/06/20 PLEASE HELP co

Posted: Thu Jul 14, 2022 2:18 pm
by answerhappygod
it shows 2022/6/20, 2021/6/20 and 2023/6/20, but I want the dateto be 2022/06/20, 2021,06/20, 2023/06/20 PLEASE HELP
It Shows 2022 6 20 2021 6 20 And 2023 6 20 But I Want The Date To Be 2022 06 20 2021 06 20 2023 06 20 Please Help Co 1
It Shows 2022 6 20 2021 6 20 And 2023 6 20 But I Want The Date To Be 2022 06 20 2021 06 20 2023 06 20 Please Help Co 1 (40.68 KiB) Viewed 25 times
correct output:
It Shows 2022 6 20 2021 6 20 And 2023 6 20 But I Want The Date To Be 2022 06 20 2021 06 20 2023 06 20 Please Help Co 2
It Shows 2022 6 20 2021 6 20 And 2023 6 20 But I Want The Date To Be 2022 06 20 2021 06 20 2023 06 20 Please Help Co 2 (87.23 KiB) Viewed 25 times
Date.cpp
#define _CRT_SECURE_NO_WARNINGS#include <iomanip>#include <iostream>#include <ctime>#include "Date.h"using namespace std;namespace sdds { bool Date::validate() { errCode(NO_ERROR); if (m_year < MIN_YEAR || m_year >m_CUR_YEAR + 1) { errCode(YEAR_ERROR); } else if (m_mon < 01 || m_mon >12) { errCode(MON_ERROR); } else if (m_day < 1 || m_day >mdays()) { errCode(DAY_ERROR); } return !bad(); } int Date::mdays()const { int days[] = { 31, 28, 31, 30, 31, 30,31, 31, 30, 31, 30, 31, -1 }; int mon = m_mon >= 01 &&m_mon <= 12 ? m_mon : 13; mon--; return days[mon] + int((mon == 01) *((m_year % 4 == 0) && (m_year % 100 != 0)) || (m_year % 400== 0)); } int Date::systemYear()const { time_t t = time(NULL); tm lt = *localtime(&t); return lt.tm_year + 1900; } void Date::setToToday() { time_t t = time(NULL); tm lt = *localtime(&t); m_day = lt.tm_mday; m_mon = lt.tm_mon + 1; m_year = lt.tm_year + 1900; errCode(NO_ERROR); } int Date::daysSince0001_1_1()const { int ty = m_year; int tm = m_mon; if (tm < 3) { ty--; tm += 12; } return 365 * ty + ty / 4 - ty / 100 +ty / 400 + (153 * tm - 457) / 5 + m_day - 306; }
Date::Date() :m_CUR_YEAR(systemYear()) { setToToday(); } Date::Date(int year, int mon, int day) :m_CUR_YEAR(systemYear()) { m_year = year; m_mon = mon; m_day = day; validate(); } const char* Date::dateStatus()const { return DATE_ERROR[errCode()]; } int Date::currentYear()const { return m_CUR_YEAR; } void Date::errCode(int readErrorCode) { m_ErrorCode = readErrorCode; } int Date::errCode()const { return m_ErrorCode; } bool Date::bad()const { return m_ErrorCode != 0; }
bool Date::extractChar(std::istream& istr,char ch) { if (istr.peek() == ch) { istr.get(); return true; } else { errCode(CIN_FAILED); istr.setstate(ios::failbit); istr.clear(); istr.ignore(80,'\n'); return false;
} }
std::istream& Date::read(std::istream&is) {
int yy, mm, dd; is >> yy; if (extractChar(is, '/')) { is >> mm; if (extractChar(is, '/'))is >> dd; else return is; } else { return is; }
if (!is.fail()) { m_year = yy; m_mon = mm; m_day = dd; validate(); } return is; }
std::ostream& Date::write(std::ostream&os)const { if (!bad()) { os << m_year<< "/" << m_mon << "/" << m_day; } else { os <<dateStatus(); } return os; }
ostream& operator<<(ostream& os,const Date& RO) { return RO.write(os); } istream& operator>>(istream& is,Date& RO) { return RO.read(is); }
long int Date::operator-(Date i)const { return (daysSince0001_1_1() -i.daysSince0001_1_1()); }
Date::operator bool() const { return !bad(); }
bool Date::operator<(const Date& d)const { if (this->m_year <d.m_year) { return true; } else if (this->m_year >d.m_year) { return false; } else { if (this->m_mon <d.m_mon) { returntrue; } else if (this->m_mon> d.m_mon) { returnfalse; } else { if(this->m_day < d.m_day) { return true; } else if(this->m_day > d.m_day) { return false; } else { return false; } }
} return false; }
bool Date::operator>(const Date&d)const { if (this->m_year >d.m_year) { return true; } else if (this->m_year <d.m_year) { return false; } else {
if (this->m_mon> d.m_mon) { returntrue; } else if (this->m_mon< d.m_mon) { returnfalse; } else { if(this->m_day > d.m_day) { return true; } else if(this->m_day < d.m_day) { return false; } else { return false; } }
} return false; }
bool Date::operator==(const Date&d)const { if (this->m_year == d.m_year&& this->m_mon == d.m_mon && this->m_day ==d.m_day) { return true; } return false; }
bool Date::operator!=(const Date&d)const { return !(*this == d); }
bool Date::operator>=(const Date&d)const { return (*this > d) || (*this ==d); }
bool Date::operator<=(const Date&d)const { return (*this < d) || (*this ==d); }}
Days between the two dates: All the following statements must be correct: 2022/6/20>2021/6/20 2022/6/20>=2021/6/20 2022/6/20>2021/6/20 2022/6/20>=2021/6/20 2022/6/20∣=2021/6/20 2022/6/20∣=2021/6/20 Days between the two dates: 365 All the following statements must be correct: 2022/6/20<2023/6/20 2022/6/20<2023/6/20 2022/6/20<2023/6/20 2022/6/20<2023/6/20 2022/6/20!=2023/6/20 2022/6/20∣=2023/6/20 Days between the two dates: −365 testing Menu Module: The ⟩< menu is empty The Lunch Menu is not empty and has 3 menu items. Lunch Menu: 1− Omelet 2− Tuna Sandwich 3− California Roll 0 - Exit
Script started on Mon 20 Jun 2022 0.5:55:45 PM EDT ==101029== Momchcck, a momory crror dctcctcr ==101029== Memchcek, a memory crror cctcctcr ==101029== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et ==101079== Using Valgrind-3.15.0 and LibVeX; rerun with −h for copyright. info ==101029== Comand: ws