c/c++

EndOfADay - C++ Builder

2022-07-31  本文已影响0人  玄坴

C++ Builder 参考手册System::DateutilsEndOfADay


某一年的某一天的结束时间,
这一年的第几天的结束时间 (23:59:59.999),
这个年、月、日的结束时间 (23:59:59.999)

头文件:#include <System.DateUtils.hpp>
命名空间:System::Dateutils
函数原型:

System::TDateTime __fastcall EndOfADay(
    const System::Word AYear,
    const System::Word ADayOfYear);

System::TDateTime __fastcall EndOfADay(
    const System::Word AYear,
    const System::Word AMonth,
    const System::Word ADay);

参数:

返回值:


例:

#include <System.DateUtils.hpp>
void __fastcall TForm1::Button1Click(TObject *Sender)
{
    TDateTime dt = Sysutils::Now();
    Memo1->Lines->Add(L"现在时间 " + FormatDateTime(L"yyyy/mm/dd hh:nn:ss.zzz", dt));
    Memo1->Lines->Add(L"今天开始 " + FormatDateTime(L"yyyy/mm/dd hh:nn:ss.zzz", StartOfTheDay(dt)));
    Memo1->Lines->Add(L"今天结束 " + FormatDateTime(L"yyyy/mm/dd hh:nn:ss.zzz", EndOfTheDay(dt)));

    unsigned short iYear = Dateutils::YearOf(dt);
    unsigned short iDoY = Dateutils::DayOfTheYear(dt);

    Memo1->Lines->Add(String().sprintf(L"今天是 %d年 的 第%d天", iYear, iDoY));
    Memo1->Lines->Add(L"今天开始 " + FormatDateTime(L"yyyy/mm/dd hh:nn:ss.zzz", StartOfADay(iYear, iDoY)));
    Memo1->Lines->Add(L"今天结束 " + FormatDateTime(L"yyyy/mm/dd hh:nn:ss.zzz", EndOfADay(iYear, iDoY)));

    unsigned short iMonth = Dateutils::MonthOf(dt);
    unsigned short iDay = Dateutils::DayOf(dt);

    Memo1->Lines->Add(String().sprintf(L"今天是 %d年%d月%d日", iYear, iMonth, iDay));
    Memo1->Lines->Add(L"今天开始 " + FormatDateTime(L"yyyy/mm/dd hh:nn:ss.zzz", StartOfADay(iYear, iMonth, iDay)));
    Memo1->Lines->Add(L"今天结束 " + FormatDateTime(L"yyyy/mm/dd hh:nn:ss.zzz", EndOfADay(iYear, iMonth, iDay)));
}

运行结果:


相关:


C++ Builder 参考手册System::DateutilsEndOfADay

上一篇下一篇

猜你喜欢

热点阅读