⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 date.cpp

📁 1.注册功能 2.登录功能 3.退出系统功能 4.发布新广告功能 5.添加子目录功能 6.查找广告功能 7.广告排序功能 8.查看当前目录中的广告 9.查看当前目录及其子目录中的广告
💻 CPP
字号:
#include <iostream>
using namespace std;

#include "Date.h"

Date::Date(void)
{
    month=0;
    day=0;
    year=0;
	hour=0;
	minute=0;
	second=0;
}
Date::Date (int month, int day, int year, int hour, int minute, int second)
{
    this->month=month;
    this->day=day;
    this->year=year;
	this->hour=hour;
	this->minute=minute;
	this->second=second;
}
void Date::setMonth(int&a)
{
	month=a;
}
void Date::setDay(int&a)
{
	day=a;
}
void Date::setYear(int&a)
{
	year=a;
}
void Date::setHour(int&a)
{
	hour=a;
}
void Date::setMinute(int&a)
{
	minute=a;
}
void Date::setSecond(int&a)
{
	second=a;
}
int Date::getMonth(void) const
{
	return month;
}
int Date::getDay(void) const
{
	return day;
}
int Date::getYear(void) const
{
	return year;
}
int Date::getHour(void) const
{
	return hour;
}
int Date::getMinute(void) const
{
	return minute;
}
int Date::getSecond(void) const
{
	return second;
}
bool Date::operator== (const Date &rhs)
{
	return (rhs.month==month&&rhs.day==day&&rhs.year==year&&rhs.hour==hour
		    &&rhs.minute==minute&&rhs.second==second);
} 
bool Date::operator< (const Date &rhs)
{
	if (rhs.year>this->year) return true;
	else if (rhs.year==this->year && rhs.month>this->month) return true;
	else if (rhs.year==this->year && rhs.month==this->month && rhs.day>this->day) return true;
	else if (rhs.year==this->year && rhs.month==this->month && rhs.day==this->day && rhs.hour>this->hour) return true;
	else if (rhs.year==this->year && rhs.month==this->month && rhs.day==this->day &&rhs.hour==this->hour&&rhs.minute>this->minute)
		    return true;
	else if (rhs.year==this->year && rhs.month==this->month && rhs.day==this->day&&rhs.hour==this->hour&&rhs.minute==this->minute&&rhs.second>this->second)
		    return true;
	else return false;
}
ostream &operator<<(ostream&stream, const Date&date) {
   int month=date.month;
   int day=date.day;
   int year=date.year;
   int hour=date.hour;
   int minute=date.minute;
   int second=date.second;
   stream << ((month<10) ? "0" : "") << month << "/" 
	      << ((day<10) ? "0" : "") << day << "/" << year << " "
	      << ((hour<10) ? "0" : "") << hour << ":"
		  << ((minute<10) ? "0" : "") << minute << ":"
		  << ((second<10) ? "0" : "") << second;
   return stream;
}
istream &operator>>(istream&stream, Date&date){
   int month,day,year,hour,minute,second;
   char x;
   stream>>month>>x;
   date.setMonth(month);
   stream>>day>>x;
   date.setDay(day);
   stream>>year;
   date.setYear(year);
   stream>>hour>>x;
   date.setHour(hour);
   stream>>minute>>x;
   date.setMinute(minute);
   stream>>second;
   date.setSecond(second);
   return stream;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -