本文整理汇总了C++中Date::GetDay方法的典型用法代码示例。如果您正苦于以下问题:C++ Date::GetDay方法的具体用法?C++ Date::GetDay怎么用?C++ Date::GetDay使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Date
的用法示例。
在下文中一共展示了Date::GetDay方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PrintDate
void PrintDate(const Date &cDate)
{
// although cDate is const, we can call const member functions
std::cout << cDate.GetMonth() << "/" <<
cDate.GetDay() << "/" <<
cDate.GetYear() << std::endl;
}
示例2: PrintDate
void PrintDate(const Date &cDate)
// void PrintDate(Date &cDate)
{
std::cout << cDate.GetDay() << "/" <<
cDate.GetMonth() << "/" <<
cDate.GetYear() << std::endl;
}
示例3: IsPayDate
bool MonthlySchedule::IsPayDate( const Date &date ) {
int day = date.GetDay();
if (day == 15) {
return true;
} else {
return false;
}
}
示例4: GetNowString
std::string Date::GetNowString()
{
Date d = Date();
char date[60] = {0};
sprintf(date, "%d-%02d-%02d %02d:%02d:%02d",
d.GetYear(),d.GetMonth(),d.GetDay(),
d.GetHour(),d.GetMinute(),d.GetSecond());
return std::string(date);
}
示例5: InitClassCode
void InitClassCode()
{
Date dateObj(6, 22, 1988);
const Date cDateObj(6, 11, 1988);
cout<<cDateObj.GetDay()<<endl;
cout<<dateObj.GetDay()<<endl;
cout<<Date::sVal<<endl;
}
示例6: if
bool Date::operator < ( Date d ) const
{
if ( m_Year < d.GetYear() )
return true;
else if ( m_Year == d.GetYear() )
{
if ( m_Month < d.GetMonth() )
return true;
else if ( m_Month == d.GetMonth() )
return m_Day < d.GetDay();
}
return false;
}
示例7: main
int main()
{
int arr[GetConst()] = { 0 };//无法使用运行时常量来初始化数组
enum{ e1 = GetConst(), e2 };//也无法使用运行时常量作为枚举值
int arr2[GetConstexpr()] = { 0 };//ok
constexpr ConstexprClass mc(0); //必须使用常量表达式赋值
//constexpr ConstexprClass mc = { 0 };等价上一条
//constexpr ConstexprClass mc{ 0 }; 等价上一条
//gcc-5.1报错:"error: passing 'const Date' as 'this' argument discards qualifiers [-fpermissive]"
constexpr Date d(1990, 11, 28);
constexpr int year = d.GetYear();
constexpr int month = d.GetMonth();
constexpr int day = d.GetDay();
std::cout << "year:" << year << std::endl
<< "month" << month << std::endl
<< "day" << day << std::endl;
//结构体NotLiteral不是定义了常量表达式构造函数的类型,因此不能够声明为常量表达式值
//而模版函数一旦以NotLiteral作为参数,那么其constexpr关键字就会被忽略
NotLiteral nl;
NotLiteral nl1 = ConstExprFun(nl);
constexpr NotLiteral nl2 = ConstExprFun(nl);//编译失败
constexpr int a = ConstExprFun(1);
constexpr Literal l1;
Literal l2 = ConstExprFun(l1);//ok
constexpr Literal l3 = ConstExprFun(l1);//ok
//constexpr函数递归
int fibs[] = { Fib(11), Fib(12), Fib(13), Fib(14), Fib(15) };
std::copy(std::begin(fibs), std::end(fibs),
std::ostream_iterator<int>(std::cout, " "));//89 144 233 377 610
std::cout << std::endl;
//使用模板元实现递归编程
int fibs2[] = { Fibo<11>::result, Fibo<12>::result, Fibo<13>::result, Fibo<14>::result, Fibo<15>::result };
std::copy(std::begin(fibs2), std::end(fibs2),
std::ostream_iterator<int>(std::cout, " "));//89 144 233 377 610
return 0;
}
示例8: DisplayInfo
void DisplayInfo()
{
cout<<"借阅信息------------------------------"<<endl;
cout<<"图书信息----------------"<<endl;
cout<<"书名:\t\t"<<inBook.GetName()<<endl;
cout<<"作者:\t\t"<<inBook.GetAuthor()<<endl;
cout<<"ISBN号:\t"<<inBook.GetISBNNum()<<endl;
cout<<"出版日期:\t"<<inBook.GetDat()<<endl;
cout<<"读者信息-----------------"<<endl;
cout<<"姓名:\t\t"<<inPatron.GetName()<<endl;
cout<<"图书卡号:\t"<<inPatron.GetCardNum()<<endl;
cout<<"借书日期:\t"<<inDate.GetYear()<<"-"<<inDate.GetMonth()<<"-"<<inDate.GetDay()<<endl;
if(inPatron.IsOwed())
cout<<"欠费信息:\t欠费"<<inPatron.GetOweCount()<<"元"<<endl;
else
cout<<"欠费信息:\t无欠费记录"<<endl;
cout<<endl;
}
示例9: genererQTimeSlot
void ZebulonWindow::genererQTimeSlot(TimeSlot* t){
QString nameCP, color;
ClassPeriod *cp = t->GetClassPeriod();
if(dynamic_cast<TutorialClass*>(cp) != NULL) {
nameCP = "Tutorial "+QString::number(cp->GetId());
color = "navy";
if(!widget.checkBoxTutorial->isChecked()) return;
}
else if(dynamic_cast<PracticalClass*>(cp) != NULL) {
nameCP = "Practical "+QString::number(cp->GetId());
color = "green";
if(!widget.checkBoxPractical->isChecked()) return;
}
else if(dynamic_cast<MagistralClass*>(cp) != NULL) {
nameCP = "Magistral "+QString::number(cp->GetId());
color = "maroon";
if(!widget.checkBoxMagistral->isChecked()) return;
}
Date *dit = t->GetStartDate();
QDate qdts = QDate(dit->GetYear(), dit->GetMonth(), dit->GetDay());
QString stringGroups = "";
list<Group*>* l = t->GetClassPeriod()->GetGroupList();
list<Group*>::iterator it = l->begin();
list<Group*>::const_iterator MaxList = l->end();
for(;it != MaxList; it++){
stringGroups.append(QString::fromStdString((*it)->GetId()));
stringGroups.append(";");
}
QTimeSlot* time = new QTimeSlot(t->GetId(), qdts, dit->GetHour(), dit->GetMin(), cp->GetDuration(),
nameCP, QString::fromStdString(t->GetClassroom()->GetId()), QString::fromStdString((cp->GetMomo()->GetId()+" : "+cp->GetMomo()->GetName())), QString::fromStdString(cp->GetTeacher()), stringGroups, NULL);
time->setBackgroundColor(color);
this->widget.edt->addTimeSlot(time);
emit signal_addTimeSlot(time);
}
示例10: isValid
// Checks if the given date is a valid date in Gregorian calendar
bool ModelValidator::isValid(const Date& date, bool allowDefaults /*= false*/)
{
if (date == Date() && !allowDefaults)
RETURN_WITH_ERROR("Date is empty");
// Check month
RETURN_IF_RANGE_NOT_VALID(date.GetMonth(), 1, 12, "Month");
// Check year
if (date.GetYear() == 0)
RETURN_WITH_ERROR("There is no 0 year in Gregorian calendar");
// Check day
int day = date.GetDay();
// 1582 - Gregorian calendar switch.
// No dates exist between october 4 and October 15
if (date.GetYear() == 1582 && date.GetMonth() == 10 && day > 4 && day < 15)
RETURN_WITH_ERROR("The year 1582 does not have dates between October 4 and October 15");
int maxDay = 31;
switch (date.GetMonth())
{
case 4:
case 6:
case 9:
case 11:
maxDay = 30;
break;
case 2:
maxDay = AIMUtil::isLeapYear(date.GetYear()) ? 29 : 28;
break;
}
RETURN_IF_RANGE_NOT_VALID(day, 0, maxDay, "Day");
return true;
}
示例11:
bool Date::operator == ( Date d ) const
{
return m_Year == d.GetYear() &&
m_Month == d.GetMonth() &&
m_Day == d.GetDay();
}