EndOfAYear - C++ Builder

C++ Builder 参考手册 ➙ System::Dateutils ➙ EndOfAYear


某一年的结束时间,这一年的 12 月 31 日 23:59:59.999

头文件:#include
命名空间:System::Dateutils
函数原型:

System::TDateTime __fastcall EndOfAYear(const System::Word AYear);

参数:

  • AYear:年,1 - 9999;

返回值:

  • AYear 年的结束时间,这一年的 12 月 31 日 23:59:59.999;
  • 在程序里面,通常判断小于下一年的1月1日00:00:00,而不是判断小于等于这一年的末尾时间;
  • 比较函数 EndOfAYear 和 EndOfTheYear:
    • EndOfAYear 的参数是一个整数年;
    • EndOfTheYear 的参数是日期时间;
    只要这两个函数参数的年相同,返回值就相同。

例:

#include 
void __fastcall TForm1::Button1Click(TObject *Sender)
{
    TDateTime dt = Sysutils::Now();
    Memo1->Lines->Add(FormatDateTime(L"yyyy/mm/dd hh:nn:ss.zzz", dt));
    Memo1->Lines->Add(FormatDateTime(L"yyyy/mm/dd hh:nn:ss.zzz", StartOfTheYear(dt)));
    Memo1->Lines->Add(FormatDateTime(L"yyyy/mm/dd hh:nn:ss.zzz", EndOfTheYear(dt)));

    unsigned short iYear = Dateutils::YearOf(dt);
    Memo1->Lines->Add(iYear);
    Memo1->Lines->Add(FormatDateTime(L"yyyy/mm/dd hh:nn:ss.zzz", StartOfAYear(iYear)));
    Memo1->Lines->Add(FormatDateTime(L"yyyy/mm/dd hh:nn:ss.zzz", EndOfAYear(iYear)));
}

运行结果:


相关:

  • System::Dateutils::StartOfTheYear
  • System::Dateutils::EndOfTheYear
  • System::Dateutils::StartOfTheMonth
  • System::Dateutils::EndOfTheMonth
  • System::Dateutils::StartOfTheWeek
  • System::Dateutils::EndOfTheWeek
  • System::Dateutils::StartOfTheDay
  • System::Dateutils::EndOfTheDay
  • System::Dateutils::StartOfAYear
  • System::Dateutils::EndOfAYear
  • System::Dateutils::StartOfAMonth
  • System::Dateutils::EndOfAMonth
  • System::Dateutils::StartOfAWeek
  • System::Dateutils::EndOfAWeek
  • System::Dateutils::StartOfADay
  • System::Dateutils::EndOfADay
  • System::Dateutils::DaysInYear
  • System::Dateutils::DaysInAYear
  • System::Dateutils::DaysInMonth
  • System::Dateutils::DaysInAMonth
  • System::Dateutils::WeeksInYear
  • System::Dateutils::WeeksInAYear
  • System::Dateutils

C++ Builder 参考手册 ➙ System::Dateutils ➙ EndOfAYear

你可能感兴趣的:(EndOfAYear - C++ Builder)