本文整理汇总了C++中IsLeapYear函数的典型用法代码示例。如果您正苦于以下问题:C++ IsLeapYear函数的具体用法?C++ IsLeapYear怎么用?C++ IsLeapYear使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了IsLeapYear函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetDateFromTimeValue
int DateTime::DayOfYear() const
{
int year, month, day;
GetDateFromTimeValue( Value(), year, month, day);
const unsigned* monthTable = IsLeapYear(year) ? monthStartLeap : monthStart;
return monthTable[ month - 1 ] + day;
}
示例2: DecodeDate
int TDateTime::IsLeapYear()
{
unsigned int year=0;
unsigned int month=0;
unsigned int day=0;
DecodeDate(year, month, day);
return IsLeapYear(year);
}
示例3: DayFromMonth
static double DayFromMonth(double year, double month)
{
int iMonth = (int) MathUtils::floor(month);
if (iMonth < 0 || iMonth >= 12) {
return MathUtils::kNaN;
}
return DayFromYear((int)year) + kMonthOffset[(int)IsLeapYear((int)year)][iMonth];
}
示例4: DayOfYear
int Date::DayOfYear(int year, int month, int day)
{
static const int DAYS_BEFORE[2][13] = {
{ -1, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 },
{ -1, 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335 }
};
return DAYS_BEFORE[IsLeapYear(year)][month] + day - 1;
}
示例5: DaysInMonth
int Date::DaysInMonth(int year, int month)
{
static const int DAYS_IN_MONTH[2][13] = {
{ 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 },
{ 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
};
return DAYS_IN_MONTH[IsLeapYear(year)][month];
}
示例6: GetAfterTwoMonthDay
Calendar Calendar::GetAfterTwoMonthDay() const {
if (this->Month == 12) {
if (!IsLeapYear(this->Year + 1)) return this->Day >= 28 ? Calendar(this->Year + 1, 2, 28) : Calendar(this->Year + 1, 2, this->Day);
else return this->Day >= 29 ? Calendar(this->Year + 1, 2, 29) : Calendar(this->Year + 1, 2, this->Day);
}
else if (this->Month == 11) return Calendar(this->Year + 1, 1, this->Day);
else if (this->Month == 7 && this->Day == 31) return Calendar(this->Year, 9, 30);
else return Calendar(this->Year, this->Month + 2, this->Day);
}
示例7: Calendar
Calendar Calendar::GetAfterAWeekDay() const {
auto AfterAWeekDate = [this](const int AbleToSimpleAddBorderDay) {
return this->Day <= AbleToSimpleAddBorderDay ? Calendar(this->Year, this->Month, this->Day + 7) : Calendar(this->Year, Month + 1, this->Day - AbleToSimpleAddBorderDay);
};
if (this->Month == 12 && this->Day > 24) return Calendar(this->Year + 1, 1, this->Day - 24);
else if (!IsNo31Month(this->Month)) return AfterAWeekDate(24);
else if (this->Month != 2) return AfterAWeekDate(23);
else return AfterAWeekDate((IsLeapYear(this->Year) ? 22 : 21));
}
示例8: DaysInYear
int32 FDateTime::DaysInYear( int32 Year )
{
if (IsLeapYear(Year))
{
return 366;
}
return 365;
}
示例9: NextDay
void NextDay(){
day++;
if(day>DayOfMonth[month][IsLeapYear(year)]){
day=1;month++;
}
if(month>12){
month=1;year++;
}
}
示例10: ValidDay
STATIC
BOOLEAN
ValidDay (
IN EFI_TIME time
)
{
if (time.Day > DayOfMonth[time.Month - 1]) {
return FALSE;
}
//
// Pay attention to month==2
//
if (time.Month == 2 && ((IsLeapYear (time) && time.Day > 29) || (!IsLeapYear (time) && time.Day > 28))) {
return FALSE;
}
return TRUE;
}
示例11: MonthDayMax
// ////////////////////////////////////////////////////////////////////////////
inline unsigned int MonthDayMax(unsigned int in_year, unsigned int in_month)
{
return((!YearMonthOk(in_year, in_month)) ? 0 :
(((in_month == 1) || (in_month == 3) ||
(in_month == 5) || (in_month == 7) || (in_month == 8) ||
(in_month == 10) || (in_month == 12)) ? 31 : ((in_month == 4) ||
(in_month == 6) || (in_month == 9) || (in_month == 11)) ? 30 :
(28 + ((IsLeapYear(in_year)) ? 1 : 0))));
}
示例12: IsDayValid
STATIC
BOOLEAN
EFIAPI
IsDayValid (
IN EFI_TIME *Time
)
{
ASSERT (Time->Day >= 1);
ASSERT (Time->Day <= mDayOfMonth[Time->Month - 1]);
ASSERT (Time->Month != 2 || IsLeapYear (Time) || Time->Day <= 28);
if (Time->Day < 1 ||
Time->Day > mDayOfMonth[Time->Month - 1] ||
(Time->Month == 2 && !IsLeapYear (Time) && Time->Day > 28)) {
return FALSE;
}
return TRUE;
}
示例13: MonthDays
int CMyCalendar::MonthDays(int year,int month)
{
if(month==2)
{
if(IsLeapYear(year))
return 29;
return 28;
}
return sMonthDays[month];
}
示例14: IsLeapYear
unsigned CTimer::GetDaysOfMonth (unsigned nMonth, unsigned nYear)
{
if ( nMonth == 1
&& IsLeapYear (nYear))
{
return 29;
}
return s_nDaysOfMonth[nMonth];
}
示例15: switch
//returns the length of any month, ie length of November would be 30
int cTimeAndDate::LengthOfMonth(int month) const {
int ret=-1;
switch(month) {
case 9: case 4: case 6: case 11: ret=30; break;
case 1: case 3: case 5: case 7: case 8: case 10: case 12: ret=31; break;
case 2: if(IsLeapYear()) ret=29; else ret=28; break;
default: ret=-1; //invalid month
}
return ret;
}