{"id":61,"date":"2008-11-12T17:10:52","date_gmt":"2008-11-12T17:10:52","guid":{"rendered":"http:\/\/kumouse.aafox.com\/?p=61"},"modified":"2008-11-12T17:10:52","modified_gmt":"2008-11-12T17:10:52","slug":"%e5%b8%b8%e7%94%a8%e6%97%a5%e6%9c%9f%e5%87%bd%e6%95%b0%ef%bc%88delphi%ef%bc%89","status":"publish","type":"post","link":"https:\/\/www.kumouse.com\/?p=61","title":{"rendered":"\u5e38\u7528\u65e5\u671f\u51fd\u6570\uff08delphi\uff09"},"content":{"rendered":"<p>\u5e38\u7528\u65e5\u671f\u51fd\u6570\uff08delphi\uff09<\/p>\n<p>Day \u5f00\u5934\u7684\u51fd\u6570<br \/>\u25cf<br \/>Unit<\/p>\n<p>DateUtils<\/p>\n<p>function DateOf(const AValue: TDateTime): TDateTime;<\/p>\n<p>\u63cf\u8ff0<br \/>\u4f7f\u7528 DateOf \u51fd\u6570\u7528\u6765\u628a\u4e00\u4e2a TDateTime \u7c7b\u578b\u7684\u53d8\u91cf\u8f6c\u53d8\u6210\u4e00\u4e2a<br \/>\u53ea\u5e26\u6709\u65e5\u671f\u7684 TDateTime \u7c7b\u578b\u53d8\u91cf\u3002<br \/>\u4f8b\u5982\uff1a<br \/>showmessage(DateTimetostr(dateof(now())));<br \/>\u4f60\u5f97\u5230\u7684\u662f 2003\/03\/19<br \/>\u800c showmessage(DateTimetostr((now())));<br \/>\u5f97\u5230\u7684\u662f 2003\/03\/19 10:50:49<\/p>\n<p>\u25cffunction DateTimeToStr(DateTime: TDateTime): string;<\/p>\n<p>\u63cf\u8ff0<br \/>DateTimeToString \u51fd\u6570\u5c06 TDateTime \u7c7b\u578b\u7684\u53c2\u6570 DateTime \u8f6c\u6362\u6210\u4e00\u4e2a<br \/>\u5b57\u7b26\u4e32\uff0c\u4f7f\u7528\u7ed9\u5b9a\u7684\u5168\u5c40\u53d8\u91cf ShortDateFormat \u7684\u683c\u5f0f\uff0c\u65f6\u95f4\u90e8\u5206\u6309\u7167<br \/>\u7ed9\u5b9a\u7684\u5168\u5c40\u53d8\u91cf LongTimeFormat \u7684\u683c\u5f0f\u3002<br \/>\u5176\u4e2d DateTime \u4e3a\u96f6\u7684\u90e8\u5206\u5c06\u4e0d\u4f1a\u663e\u793a\u51fa\u6765\u3002<\/p>\n<p>\u4f8b\u5982\uff1a<br \/>ShortDateFormat:=&#39;yyyy mm dd&#39;;<br \/>showmessage(DateTimetostr((now())));<br \/>\u4f60\u5c06\u5f97\u5230\uff1a2003 03 19 10:50:49<\/p>\n<p>\u25cfprocedure DateTimeToString(var Result: string; const Format: string; DateTime: TDateTime);<\/p>\n<p>\u63cf\u8ff0\uff1a<br \/>DateTimeToString \u65b9\u6cd5\u5c06TDateTime\u7c7b\u578b\u7684\u53c2\u6570DateTime \u6309\u7167\u7531\u53c2\u6570Format\u63d0\u4f9b\u7684\u683c\u5f0f<br \/>\u8f6c\u5316\u6210\u5b57\u7b26\u4e32\uff0c\u5e76\u4fdd\u5b58\u5728Result\u4e2d\u3002<br \/>\u5bf9\u4e8eFormat\u7684\u683c\u5f0f\u7c7b\u578b\uff0c\u8bf7\u770b Date-Time format strings \u7684\u5e2e\u52a9\u3002<\/p>\n<p>\u4f8b\u5982\uff1a <br \/>DateTimeToString(result,&#39;yyyy mm dd&#39;,now());<br \/>\u90a3\u4e48 result\u7684\u7ed3\u679c\u4e3a\uff1a2003 03 19 10:50:49<\/p>\n<p>\u25cfprocedure DateTimeToSystemTime(DateTime: TDateTime; var SystemTime: TSystemTime);<\/p>\n<p>\u63cf\u8ff0\uff1a<br \/>\u6709\u65f6\u4e3a\u4e86\u8c03\u7528API\u51fd\u6570\u6765\u4f7f\u7528\u7cfb\u7edf\u65f6\u95f4\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528 DateTimeToSystemTime \u65b9\u6cd5\uff0c\u6765\u5c06\u4e00\u4e2a<br \/>TDateTime \u7c7b\u578b\u7684\u65f6\u95f4\u53d8\u91cf\u8f6c\u6362\u6210\u4e00\u4e2a TSystemTime \u7c7b\u578b\u7684 \u7cfb\u7edf\u65f6\u95f4\u3002<\/p>\n<p>\u25cffunction DateTimeToUnix(const AValue: TDateTime ): Int64;<\/p>\n<p>\u63cf\u8ff0\uff1a<br \/>\u4f7f\u7528 DateTimeToUnix \u51fd\u6570\u6765\u5c06\u4e00\u4e2a TDateTime \u578b\u65f6\u95f4\u53d8\u91cf\u8f6c\u6362\u6210\u4e00\u4e2a\u76f8\u5e94\u7684 Unix \u683c\u5f0f<br \/>\u7684\u65e5\u671f\u548c\u65f6\u95f4\u3002<br \/>Unix date-and-time values are encoded as the number of seconds that have elapsed<br \/>since midnight at the start of January 1, 1970.<\/p>\n<p>\u25cffunction DateToStr(Date: TDateTime): string;<\/p>\n<p>\u63cf\u8ff0\uff1a<br \/>\u4f7f\u7528 DateToStr \u51fd\u6570\u80fd\u5f97\u5230 TDateTime \u65e5\u671f\u65f6\u95f4\u7c7b\u578b\u7684\u65e5\u671f\u90e8\u5206\u3002\u65e5\u671f\u7684\u8f6c\u6362\u683c\u5f0f\u4f9d\u8d56\u4e8e<br \/>\u5168\u5c40\u53d8\u91cf ShortDateFormat\u3002<\/p>\n<p>\u25cffunction DayOf(const AValue: TDateTime): Word;<\/p>\n<p>\u63cf\u8ff0\uff1a<br \/>\u5bf9\u4e8e\u7ed9\u5b9a\u7684TDateTime\u7c7b\u578b\u7684\u65e5\u671f\u65f6\u95f4\uff0c\u4f7f\u7528 DayOf \u51fd\u6570\u80fd\u5f97\u5230\u8be5\u65e5\u671f\u662f\u8be5\u6708\u4efd\u7684\u7b2c\u51e0\u5929\u3002<br \/>\u8be5\u51fd\u6570\u7684\u8fd4\u56de\u6570\u503c\u5728 1 \u5230 31 \u4e4b\u95f4<br \/>\u6ce8\u610f\uff1aDayOf \u51fd\u6570\u5f97\u5230\u7684\u7ed3\u679c\u4e0e DayOfTheMonth \u76f8\u540c\u3002<\/p>\n<p>\u4f8b\u5982\uff1a<br \/>showmessage(inttostr(dayof(now)));<br \/>\u5f97\u5230\u7684\u662f\uff1a19 \uff08\u4eca\u5929\u662f \u67d0\u670819\u65e5\uff09<\/p>\n<p>\u25cffunction DayOfTheMonth(const AValue: TDateTime): Word;<\/p>\n<p>\u4e0e DayOf \u76f8\u540c\u3002<\/p>\n<p>\u25cffunction DayOfTheWeek(const AValue: TDateTime): Word;<\/p>\n<p>\u63cf\u8ff0\uff1a<br \/>\u5bf9\u4e8e\u7ed9\u5b9a\u7684TDateTime\u7c7b\u578b\u7684\u65e5\u671f\u65f6\u95f4\uff0c\u4f7f\u7528 DayOfTheWeek \u51fd\u6570\u80fd\u5f97\u5230\u8be5\u65e5\u671f\u662f\u8be5\u661f\u671f\u7684<br \/>\u7b2c\u51e0\u5929\u3002DayOfTheWeek \u51fd\u6570\u7684\u8fd4\u56de\u6570\u503c\u4e3a 1 \u5230 7\uff0c\u5176\u4e2d 1 \u8868\u793a\u661f\u671f\u4e00\uff0c\u800c 7 \u8868\u793a\u661f\u671f\u65e5\u3002<br \/>\u6ce8\u610f\uff1aDayOfTheWeek \u662f ISO 8601 \u6807\u51c6\u7684\uff08\u6b64\u6807\u51c6\u4e3a \u661f\u671f\u4e00\u662f\u4e00\u5468\u7684\u7b2c\u4e00\u5929\uff09\u3002\u5bf9\u4e8e\u4e00\u5468<br \/>\u7684\u7b2c\u4e00\u5929\u662f\u661f\u671f\u65e5\u7684\u6807\u51c6\uff0c\u5982\u679c\u60f3\u83b7\u5f97\u661f\u671f\u6570\uff0c\u8bf7\u4f7f\u7528 DayOfWeek \u51fd\u6570\u3002<br \/>Tip: To make the return value more readable, use the Day of week constants.<\/p>\n<p>\u25cffunction DayOfTheYear(const AValue: TDateTime): Word;<\/p>\n<p>\u63cf\u8ff0\uff1a<br \/>\u6839\u636e\u7ed9\u5b9a\u7684\u65e5\u671f\u65f6\u95f4\u53c2\u6570AValue\uff0c\u4f7f\u7528 DayOfTheYear \u51fd\u6570\u80fd\u5f97\u5230\u5728\u8be5\u65e5\u671f\u6240\u5728\u7684\u5e74\u4efd\u4e2d\uff0c\u8be5<br \/>\u65e5\u671f\u6309\u7167\u987a\u5e8f\u6240\u8ba1\u7b97\u7684\u5929\u6570\u3002\u56e0\u6b64\uff0c\u4f5c\u4e3aTDateTime\u7c7b\u578b\u7684\u53d8\u91cf \u201c1\u67081\u65e5\u201d\u5728\u8be5\u51fd\u6570\u6240\u5f97\u5230\u7684<br \/>\u7ed3\u679c\u4e3a 1 \uff0c\u201c1\u67082\u65e5\u201d\u6240\u5f97\u5230\u7684\u7ed3\u679c\u4e3a 2\uff0c\u201c2\u67081\u65e5\u201d\u6240\u5f97\u5230\u7684\u7ed3\u679c\u5c31\u4e3a 32\uff0c\u4f9d\u6b21\u7c7b\u63a8\u3002<\/p>\n<p>\u25cffunction DayOfWeek(Date: TDateTime): Integer;<\/p>\n<p>Description<\/p>\n<p>DayOfWeek returns the day of the week of the specified date as an integer between<br \/>1 and 7, where Sunday is the first day of the week and Saturday is the seventh.<\/p>\n<p>Note: DayOfWeek is not compliant with the ISO 8601 standard, which defines Monday<br \/>as the first day of the week. For an ISO 8601 compliant version, use the DayOfTheWeek<br \/>function instead.<\/p>\n<p>\u63cf\u8ff0\uff1a<br \/>\u6309\u7167\u7ed9\u5b9a\u7684TDateTime\u7c7b\u578b\u7684\u53c2\u6570Date\uff0cDayOfWeek \u51fd\u6570\u5f97\u5230\u4e00\u5468\u4e2d\u7684\u7b2c\u51e0\u5929\uff0c\u4ece1\u52307\u3002<br \/>\u8fd9\u91cc \u661f\u671f\u65e5 \u662f\u4e00\u5468\u7684\u7b2c\u4e00\u5929\uff0c\u800c \u661f\u671f\u516d \u662f\u7b2c\u4e03\u5929\u3002<\/p>\n<p>\u25cffunction DaysBetween(const ANow, AThen: TDateTime): Integer;<\/p>\n<p>\u63cf\u8ff0\uff1a<br \/>\u6839\u636e\u4e24\u4e2aTDateTime\u7c7b\u578b\u7684\u65e5\u671f\u65f6\u95f4\u53d8\u91cf ANow \u548c AThen\uff0cDaysBetween\u51fd\u6570\u80fd\u5f97\u5230\u4e24\u8005\u4e4b\u95f4\u7684<br \/>\u5929\u6570\u7684\u5dee\u8ddd\u3002<br \/>DaysBetween \u4ec5\u4ec5\u6839\u636e\u5929\u6570\u7684\u4e0d\u540c\u6765\u8ba1\u7b97\u3002\u56e0\u6b64\uff0c\u5bf9\u4e8e 1999\u5e7412\u670831\u65e5 \u4e0b\u534811\u70b959\u5206 \u5230<br \/>2000\u5e741\u67081\u65e5 11\u70b958\u5206\uff0c\u8be5\u51fd\u6570\u5f97\u5230\u7684\u7ed3\u679c\u662f 0\uff0c\u56e0\u4e3a\u4e24\u8005\u4e4b\u95f4\u7684\u65f6\u95f4\u5dee\u522b\u8fd8\u5dee 1 \u5206\u949f\u624d\u5230<br \/>1 \u5929\u3002<\/p>\n<p>\u25cffunction DaysInAMonth(const AYear, AMonth: Word): Word;<\/p>\n<p>\u63cf\u8ff0\uff1a<br \/>\u5bf9\u4e8e\u5404\u5b9a\u7684 \u5e74\u4efd\u548c\u6708\u4efd\uff0cDaysInAMonth \u51fd\u6570\u80fd\u5f97\u5230 \u8be5\u6708\u4efd\u7684\u603b\u5929\u6570\u3002<br \/>\u5e74\u4efd\u5e94\u8be5\u4e3a \u4ece 1 \u5230 9999<br \/>\u6708\u4efd\u5e94\u8be5\u4e3a \u4ece 1 \u5230 12<\/p>\n<p>\u25cffunction DaysInAYear(const AYear: Word): Word;<\/p>\n<p>\u63cf\u8ff0\uff1a<br \/>\u5bf9\u4e8e\u7ed9\u5b9a\u7684\u5e74\u4efd\uff0cDaysInAYear\u51fd\u6570\u80fd\u5f97\u5230\u8be5\u5e74\u4efd\u7684\u603b\u5929\u6570\u3002<br \/>\u5e74\u4efd\u5e94\u8be5\u4e3a 1 \u5230 9999\u3002<\/p>\n<p>\u25cffunction DaysInMonth(const AValue: TDateTime): Word;<\/p>\n<p>\u63cf\u8ff0\uff1a<br \/>\u6839\u636e\u7ed9\u5b9a\u7684TDateTime\u7c7b\u578b\u7684\u65f6\u95f4\u65e5\u671f\u53c2\u6570AValue\uff0cDaysInMonth\u51fd\u6570\u80fd\u5f97\u5230\u8be5\u6708\u4efd\u7684\u603b\u5929\u6570\u3002<\/p>\n<p>\u25cffunction DaysInYear(const AValue: TDateTime): Word;<\/p>\n<p>\u63cf\u8ff0\uff1a<br \/>\u6839\u636e\u7ed9\u5b9a\u7684TDateTime\u7c7b\u578b\u7684\u65f6\u95f4\u65e5\u671f\u53c2\u6570AValue\uff0cDaysInYear\u51fd\u6570\u80fd\u5f97\u5230\u8be5\u5e74\u4efd\u7684\u603b\u5929\u6570\u3002<\/p>\n<p>\u25cffunction DaySpan(const ANow, AThen: TDateTime): Double;<\/p>\n<p>\u63cf\u8ff0\uff1a<br \/>\u6839\u636e\u4e24\u4e2aTDateTime\u7c7b\u578b\u7684\u65e5\u671f\u65f6\u95f4\u53c2\u6570ANow\u548cAThen\uff0cDaySpan\u80fd\u5f97\u5230\u5728\u5929\u6570\u4e0a\u7684\u5dee\u8ddd\u3002<br \/>\u4e0e DaysBetween \u51fd\u6570\u4e0d\u540c\uff0cDaysBetween \u51fd\u6570 \u53ea\u662f\u8ba1\u7b97 \u6574\u7684\u5929\u6570\uff0c\u800c DaySpan\u51fd\u6570\u4f1a<br \/>\u5c06\u4e0d\u8db3\u4e00\u5929\u7684\u6570\u4e5f\u5f97\u5230\u3002<br \/>\u6ce8\u610f\uff1a\u6b64\u51fd\u6570\u8fd4\u56de\u7684\u6570\u503c\u4e3a Double \u578b\u3002<\/p>\n<p>\u2606 Month \u5f00\u5934\u7684\u51fd\u6570<\/p>\n<p>\u25cffunction MonthOf(const AValue: TDateTime): Word;<\/p>\n<p>\u63cf\u8ff0\uff1a<br \/>\u6839\u636e\u7ed9\u5b9a\u7684TDateTime\u7c7b\u578b\u7684\u65f6\u95f4\u65e5\u671f\u53c2\u6570AValue\uff0cMonthOf\u51fd\u6570\u80fd\u5f97\u5230\u8be5\u5e74\u4efd\u7684\u8be5\u6708\u4efd\u6570\u3002<br \/>MonthOf\u8fd4\u56de\u6570\u503c\u4e3a 1 \u5230 12\u3002<br \/>\u6ce8\u610f\uff1aMonthOf\u51fd\u6570\u5f97\u5230\u7684\u6570\u503c\u4e0eMonthOfTheYear\u51fd\u6570\u76f8\u540c<\/p>\n<p>\u25cffunction MonthOfTheYear(const AValue: TDateTime): Word;<\/p>\n<p>\u4e0eMonthOf\u51fd\u6570\u76f8\u540c\u3002<\/p>\n<p>\u25cffunction MonthsBetween(const ANow, AThen: TDateTime): Integer;<\/p>\n<p>\u63cf\u8ff0\uff1a<br \/>\u6839\u636e\u4e24\u4e2a\u7ed9\u5b9a\u7684TDateTime\u7c7b\u578b\u7684\u53c2\u6570ANow\u548cAThen\uff0cMonthsBetween\u51fd\u6570\u80fd\u5f97\u5230\u4e24\u4e2a\u65e5\u671f\u5728\u6708\u4efd<br \/>\u4e0a\u5dee\u8ddd\u6570\u3002\u56e0\u4e3a\u6708\u4efd\u7684\u5929\u6570\u662f\u4e0d\u540c\u7684\uff0c\u6240\u4ee5 MonthsBetween \u51fd\u6570\u8fd4\u56de\u7684\u662f\u4e00\u4e2a\u8fd1\u4f3c\u503c\uff0c\u8be5\u8fd1\u4f3c<br \/>\u503c\u57fa\u4e8e\u6bcf\u4e2a\u6708\u4efd\u4e3a 30.4375 \u5929\u3002\u4e0d\u8db3\u4e00\u4e2a\u6708\u7684\u6570\u5b57\u5c06\u4e0d\u88ab\u8ba1\u7b97\u3002<br \/>\u56e0\u6b64\uff0c\u4f8b\u5982\uff0c\u5bf9\u4e8e 2\u67081\u65e5 \u5230 2\u670828\u65e5\uff0cMonthsBetween \u8fd4\u56de\u7684\u6570\u503c\u4e3a 0\u3002<br \/>\u540c\u6837\uff0c\u5bf9\u4e8e 2\u67081\u65e5 \u5230 3\u67081\u65e5\uff0cMonthsBetween \u8fd4\u56de\u7684\u6570\u503c\u4e5f\u662f 0\u3002<\/p>\n<p>\u25cffunction MonthSpan(const ANow, AThen: TDateTime): Double;<\/p>\n<p>\u63cf\u8ff0\uff1a<br \/>\u6839\u636e\u4e24\u4e2a\u7ed9\u5b9a\u7684TDateTime\u7c7b\u578b\u7684\u53c2\u6570ANow\u548cAThen\uff0cMonthsBetween\u51fd\u6570\u80fd\u5f97\u5230\u4e24\u4e2a\u65e5\u671f\u5728\u6708\u4efd<br \/>\u4e0a\u5dee\u8ddd\u6570\u3002\u56e0\u4e3a\u6708\u4efd\u7684\u5929\u6570\u662f\u4e0d\u540c\u7684\uff0c\u6240\u4ee5 MonthsBetween \u51fd\u6570\u8fd4\u56de\u7684\u662f\u4e00\u4e2a\u8fd1\u4f3c\u503c\uff0c\u8be5\u8fd1\u4f3c<br \/>\u503c\u57fa\u4e8e\u6bcf\u4e2a\u6708\u4efd\u4e3a 30.4375 \u5929\u3002\u4e0e MonthsBetween \u51fd\u6570\u4e0d\u540c\uff0cMonthsBetween\u51fd\u6570\u4e0d\u8ba1\u7b97\u4e0d\u8db3<br \/>\u4e00\u4e2a\u6708\u7684\u6570\u5b57\uff0cMonthSpan\u51fd\u6570\u5c06\u4f1a\u5f97\u5230\u4e0d\u8db3\u4e00\u4e2a\u6708\u7684\u6570\u5b57\u3002<br \/>\u6ce8\u610f\uff1a\u6b64\u51fd\u6570\u8fd4\u56de\u7684\u7c7b\u578b\u4e3a Double<\/p>\n<p>\u25cffunction MonthStr(DateTime: TDateTime): string;<\/p>\n<p>Description<\/p>\n<p>HTTP me<\/p>\n<p>ssage headers permit several formats for the representation of date and time <br \/>values. MonthStr converts a TDateTime value into a string representing the month. <br \/>MonthStr allows server applications to work with date values taken from HTTP request <br \/>messages, without worrying about the details of how they are formatted.<\/p>\n<p>\u2606 Week \u5f00\u5934\u7684\u51fd\u6570<\/p>\n<p>\u25cffunction WeekOf(const AValue: TDateTime): Word;<\/p>\n<p>\u63cf\u8ff0\uff1a<br \/>\u6839\u636eTDateTime\u7c7b\u578b\u7684\u65e5\u671f\u65f6\u95f4\u53c2\u6570AValu\uff0cWeekOf\u51fd\u6570\u4f1a\u5f97\u5230\u8be5\u661f\u671f\u4e3a\u4e00\u5e74\u7684\u7b2c\u51e0\u4e2a<br \/>\u661f\u671f\u3002<\/p>\n<p>\u25cffunction WeeksInAYear(const AYear: Word): Word;<\/p>\n<p>\u63cf\u8ff0\uff1a<br \/>WeeksInAYear \u51fd\u6570\u6839\u636e\u5e74\u4efd\u5f97\u5230\u5728\u8be5\u5e74\u4efd\u4e2d\u5171\u5305\u542b\u591a\u5c11\u4e2a\u661f\u671f\u3002<\/p>\n<p>\u25cffunction WeeksBetween(const ANow, AThen: TDateTime): Integer;<\/p>\n<p>\u63cf\u8ff0\uff1a<br \/>\u6839\u636e\u4e24\u4e2aTDateTime\u7c7b\u578b\u7684\u65e5\u671f\u65f6\u95f4\u53c2\u6570ANow\u548cAThen\uff0cWeeksBetween\u51fd\u6570\u5c06\u5f97\u5230\u8fd9\u4e24\u4e2a\u65f6\u95f4\u5728<br \/>\u661f\u671f\u4e0a\u7684\u5dee\u6570\u3002\u5982\u679c\u5dee\u6570\u4e0d\u8db3\u4e00\u4e2a\u661f\u671f\uff0c\u5219\u5ffd\u7565\u6389\u3002<\/p>\n<p>\u25cffunction WeekSpan(const ANow, AThen: TDateTime): Double;<\/p>\n<p>\u63cf\u8ff0\uff1a<br \/>\u6839\u636e\u4e24\u4e2aTDateTime\u7c7b\u578b\u7684\u65e5\u671f\u65f6\u95f4\u53c2\u6570ANow\u548cAThen\uff0cWeeksBetween\u51fd\u6570\u5c06\u5f97\u5230\u8fd9\u4e24\u4e2a\u65f6\u95f4\u5728<br \/>\u661f\u671f\u4e0a\u7684\u5dee\u6570\u3002\u5982\u679c\u5dee\u6570\u4e0d\u8db3\u4e00\u4e2a\u661f\u671f\uff0c\u5219WeekSpan\u51fd\u6570\u4e0d\u4f1a\u5ffd\u7565\u6389\u3002<br \/>\u6ce8\u610f\uff1a\u6b64\u51fd\u6570\u7684\u8fd4\u56de\u7c7b\u578b\u4e3a Double<\/p>\n<p>\u2606 Year \u5f00\u5934\u7684\u51fd\u6570<\/p>\n<p>\u25cffunction YearOf(const AValue: TDateTime): Word;<\/p>\n<p>\u63cf\u8ff0\uff1a<br \/>\u6839\u636e\u7ed9\u5b9a\u7684TDateTime\u7c7b\u578b\u7684\u65e5\u671f\u65f6\u95f4\u53c2\u6570AValue\uff0cYearOf\u51fd\u6570\u80fd\u5f97\u5230\u8be5\u65e5\u671f\u7684\u5e74\u4efd\u6570\u5b57\u3002<br \/>YearOf\u51fd\u6570\u8fd4\u56de\u7684\u6570\u503c\u4e3a\u4ece 1 \u5230 9999<\/p>\n<p>\u25cffunction YearsBetween(const ANow, AThen: TDateTime): Integer;<\/p>\n<p>\u63cf\u8ff0\uff1a<br \/>\u6839\u636e\u4e24\u4e2a\u7ed9\u5b9a\u7684TDateTime\u7c7b\u578b\u7684\u53c2\u6570ANow\u548cAThen\uff0cYearsBetween\u51fd\u6570\u80fd\u5f97\u5230\u4e24\u4e2a\u65e5\u671f\u5728\u5e74\u4efd<br \/>\u4e0a\u5dee\u8ddd\u6570\u3002\u56e0\u4e3a\u5e74\u4efd\u7684\u5929\u6570\u662f\u4e0d\u540c\u7684\uff0c\u6240\u4ee5 YearsBetween \u51fd\u6570\u8fd4\u56de\u7684\u662f\u4e00\u4e2a\u8fd1\u4f3c\u503c\uff0c\u8be5\u8fd1\u4f3c<br \/>\u503c\u57fa\u4e8e\u6bcf\u5e74\u7684\u5929\u6570\u4e3a 365.25 \u5929\u3002\u4e0d\u8db3\u7684\u4e00\u5e74\u7684\u5dee\u8ddd\u5c06\u4e0d\u4f1a\u88ab\u8ba1\u7b97\u3002<br \/>\u56e0\u6b64\u4f8b\u5982\uff1a\u5bf9\u4e8e 1\u67081\u65e5\u548c12\u670831\u65e5\uff0c\u5982\u679c\u8fd9\u4e24\u4e2a\u65e5\u671f\u5728\u540c\u4e00\u5e74\uff0c\u5219 YearsBetween \u8fd4\u56de\u6570\u503c<br \/>\u4e3a 0\uff1b\u5982\u679c\u8fd9\u4e24\u4e2a\u65e5\u671f\u5728\u4e34\u8fd1\u7684\u5e74\u4efd\uff0c\u5219 YearsBetween \u51fd\u6570\u8fd4\u56de\u6570\u503c\u4e3a 1\u3002<\/p>\n<p>\u25cffunction YearSpan(const ANow, AThen: TDateTime): Double;<\/p>\n<p>\u63cf\u8ff0\uff1a<br \/>\u6839\u636e\u4e24\u4e2a\u7ed9\u5b9a\u7684TDateTime\u7c7b\u578b\u7684\u53c2\u6570ANow\u548cAThen\uff0cYearsBetween\u51fd\u6570\u80fd\u5f97\u5230\u4e24\u4e2a\u65e5\u671f\u5728\u5e74\u4efd<br \/>\u4e0a\u5dee\u8ddd\u6570\u3002\u56e0\u4e3a\u5e74\u4efd\u7684\u5929\u6570\u662f\u4e0d\u540c\u7684\uff0c\u6240\u4ee5 YearsBetween \u51fd\u6570\u8fd4\u56de\u7684\u662f\u4e00\u4e2a\u8fd1\u4f3c\u503c\uff0c\u8be5\u8fd1\u4f3c<br \/>\u503c\u57fa\u4e8e\u6bcf\u5e74\u7684\u5929\u6570\u4e3a 365.25 \u5929\u3002\u4e0e YearsBetween \u51fd\u6570\u4e0d\u540c\uff0cYearsBetween\u51fd\u6570\u5c06\u5ffd\u7565\u6389\u4e0d<br \/>\u8db3\u4e00\u5e74\u7684\u6570\u5b57\uff0c\u800c YearSpan \u5c06\u8ba1\u7b97\u4e0d\u8db3\u4e00\u5e74\u7684\u6570\u5b57\u3002<br \/>\u6ce8\u610f\uff1a\u8be5\u51fd\u6570\u8fd4\u56de\u7c7b\u578b\u4e3aDouble <\/p>\n<p>\u25cffunction Yesterday: TDateTime;<\/p>\n<p>\u63cf\u8ff0\uff1a<br \/>Yesterday\u51fd\u6570\u80fd\u5f97\u5230\u5f53\u524d\u65e5\u671f\u7684\u524d\u4e00\u5929\u7684\u65e5\u671f\uff0c\u8fd4\u56de\u6570\u503c\u4e2d\u4e0d\u5305\u62ec\u65f6\u95f4\u90e8\u5206\u3002<br \/>\u4f8b\u5982\uff1a<br \/>\u5f53\u524d\u65e5\u671f\u662f 2003\/3\/19<br \/>\u5219 showmessage(datetimetostr(Yesterday));<br \/>\u5c06\u5f97\u5230 2003\/3\/18<\/p>\n<p>\u2606\u65e5\u671f\u7684\u5408\u6210<br \/>\u25cffunction EncodeDate(Year, Month, Day: Word): TDateTime;<\/p>\n<p>\u63cf\u8ff0\uff1a<br \/>EncodeDate\u51fd\u6570\u5c06\u6839\u636e\u53c2\u6570 \u5e74\u4efd\u3001\u6708\u4efd\u3001\u65e5\u5b50 \u800c\u5f97\u5230\u4e00\u4e2aTDateTime\u7c7b\u578b\u7684\u65f6\u95f4\u53d8\u91cf\u3002<\/p>\n<p>\u25cffunction EncodeDateDay(const AYear, ADayOfYear: Word): TDateTime;<\/p>\n<p>\u63cf\u8ff0\uff1a<br \/>EncodeDateDay\u5c06\u6839\u636e\u53c2\u6570\u5e74\u4efd\u548c\u5929\u6570\uff0c\u800c\u5f97\u5230\u4e00\u4e2aTDateTime\u7c7b\u578b\u7684\u65f6\u95f4\u53d8\u91cf\u3002<br \/>\u5176\u4e2dAYear \u4e3a 1 \u5230 9999\u3002<br \/>ADayOfYear \u4e3a\u65e5\u5b50\u5728\u8be5\u5e74\u4efd\u987a\u5e8f\u6392\u5217\u7684\u5929\u6570\uff0c\u4f8b\u5982\uff0c1\u67081\u65e5\u65f6\uff0cADayOfYear\u4e3a1\uff0c<br \/>2\u67082\u65e5\u65f6\uff0cADayOfYear\u4e3a2\uff0c3\u67081\u65e5\u65f6\uff0cADayOfYear\u4e3a32\u3002<\/p>\n<p>\u25cffunction EncodeDateMonthWeek(const AYear, AMonth, AWeekOfMonth: Word; const ADayOfWeek: Word = <\/p>\n<p>1): TDateTime;<\/p>\n<p>\u63cf\u8ff0\uff1a<br \/>EncodeDateMonthWeek \u51fd\u6570\u5c06\u6839\u636e\u53c2\u6570 \u5e74\u4efd\u3001\u6708\u4efd\u3001\u661f\u671f\u6570\uff0c\u661f\u671f\u51e0\uff0c\u6765\u5f97\u5230\u4e00\u4e2aTDateTime\u7c7b\u578b<br \/>\u7684\u65f6\u95f4\u53d8\u91cf\u3002<br \/>\u5176\u4e2dAYear \u4e3a 1 \u5230 9999\u3002<br \/>\u5176\u4e2dAMonth \u4e3a 1 \u5230 12\u3002<br \/>AWeekOfMonth\u662f\u5728\u8be5\u6708\u4efd\u7684\u661f\u671f\u6570\uff0c1 \u8868\u793a\u7b2c\u4e00\u4e2a\u661f\u671f\uff0c\u53ef\u80fd\u5305\u542b4\u5929\u6216\u66f4\u591a\u7684\u5929\u6570\u3002<br \/>\u6ce8\u610f\uff0c\u4e00\u4e2a\u6708\u7684\u7b2c\u4e00\u5929\u5982\u679c\u662f \u661f\u671f5\uff0c\u661f\u671f6\u6216\u661f\u671f\u65e5\uff0c\u7528\u8868\u793a\u8fd9\u4e09\u5929\u7684AMonth\u6570\u503c\u5fc5\u987b\u8bbe\u5b9a<br \/>\u4e3a\u4e0a\u4e00\u4e2a\u6708\u4efd\u7684\u6570\u5b57\uff0c\u540c\u65f6 AWeekOfMonth \u8981\u8bbe\u4e3a\u5728\u4e0a\u4e00\u4e2a\u6708\u6240\u5728\u7684\u661f\u671f\u6570\u3002<br \/>\u540c\u6837\uff0c\u5982\u679c\u4e00\u4e2a\u6708\u7684\u6700\u540e\u4e00\u5929\u662f \u661f\u671f1\uff0c\u661f\u671f2\uff0c\u6216\u661f\u671f3\uff0c\u90a3\u4e48\u7528\u8868\u793a\u8fd9\u4e09\u5929\u7684AMonth\u6570\u503c<br \/>\u5fc5\u987b\u8bbe\u5b9a\u4e3a\u4e0b\u4e00\u4e2a\u6708\u4efd\u7684\u6570\u5b57\uff0c\u540c\u65f6 AWeekOfMonth \u4e3a 1\u3002<br \/>ADayOfWeek\u8868\u793a\u661f\u671f\u51e0\uff0c\u661f\u671f\u4e00\u4e3a1\uff0c\u661f\u671f\u4e8c\u4e3a2\u3002 <\/p>\n<p>\u25cffunction EncodeDateTime(const AYear, AMonth, ADay, AHour, AMinute, ASecond, AMilliSecond: <\/p>\n<p>Word):TDateTime;<\/p>\n<p>\u63cf\u8ff0\uff1a<br \/>EncodeDateTime \u6839\u636e\u53c2\u6570 \u5e74\u4efd\u3001\u6708\u4efd\u3001\u65e5\u5b50\u3001\u5c0f\u65f6\u3001\u5206\u3001\u79d2\u3001\u6beb\u79d2 \u6765\u5f97\u5230\u4e00\u4e2aTDateTime\u7c7b\u578b<br \/>\u65e5\u671f\u65f6\u95f4\u3002<\/p>\n<p>\u25cffunction EncodeDateWeek(const AYear, AWeekOfYear: Word; const ADayOfWeek: Word = 1): TDateTime;<\/p>\n<p>\u63cf\u8ff0\uff1a<\/p>\n<p>EncodeDateWeek \u6839\u636e\u53c2\u6570 \u5e74\u4efd\u3001\u661f\u671f\u6570\u3001\u661f\u671f\u51e0 \u6765\u5f97\u5230\u4e00\u4e2aTDateTime\u7c7b\u578b\u65e5\u671f\u65f6\u95f4\u3002<\/p>\n<p>AWeekOfYear\u662f\u5728\u8be5\u5e74\u4efd\u7684\u661f\u671f\u6570\uff0c1 \u8868\u793a\u7b2c\u4e00\u4e2a\u661f\u671f\uff0c\u53ef\u80fd\u5305\u542b4\u5929\u6216\u66f4\u591a\u7684\u5929\u6570\u3002<br \/>\u6ce8\u610f\uff0c\u4e00\u5e74\u7684\u7b2c\u4e00\u5929\u5982\u679c\u662f \u661f\u671f5\uff0c\u661f\u671f6\u6216\u661f\u671f\u65e5\uff0c\u7528\u8868\u793a\u8fd9\u4e09\u5929\u7684AYear\u6570\u503c\u5fc5\u987b\u8bbe\u5b9a<br \/>\u4e3a\u4e0a\u4e00\u4e2a\u5e74\u4efd\u7684\u6570\u5b57\uff0c\u540c\u65f6 AWeekOfYear \u8981\u8bbe\u4e3a\u5728\u4e0a\u4e00\u4e2a\u5e74\u6240\u5728\u7684\u661f\u671f\u6570\u3002<br \/>\u540c\u6837\uff0c\u5982\u679c\u4e00\u5e74\u7684\u6700\u540e\u4e00\u5929\u662f \u661f\u671f1\uff0c\u661f\u671f2\uff0c\u6216\u661f\u671f3\uff0c\u90a3\u4e48\u7528\u8868\u793a\u8fd9\u4e09\u5929\u7684AYear\u6570\u503c<br \/>\u5fc5\u987b\u8bbe\u5b9a\u4e3a\u4e0b\u4e00\u4e2a\u5e74\u4efd\u7684\u6570\u5b57\uff0c\u540c\u65f6 AWeekOfYear \u4e3a 1\u3002<br \/>ADayOfWeek\u8868\u793a\u661f\u671f\u51e0\uff0c\u661f\u671f\u4e00\u4e3a1\uff0c\u661f\u671f\u4e8c\u4e3a2\u3002<\/p>\n<p>\u25cffunction EncodeTime(Hour, Min, Sec, MSec: Word): TDateTime;<\/p>\n<p>\u63cf\u8ff0\uff1a<br \/>EncodeTime\u51fd\u6570\u6839\u636e\u53c2\u6570 \u5c0f\u65f6\u3001\u5206\u3001\u79d2\u3001\u6beb\u79d2 \u5f97\u5230\u4e2a\u4e00\u4e2aTDateTime\u6570\u503c\u3002<\/p>\n<p>\u2606\u65e5\u671f\u7684\u5206\u89e3<\/p>\n<p>\u25cfprocedure DecodeDate(Date: TDateTime; var Year, Month, Day: Word);<\/p>\n<p>\u63cf\u8ff0\uff1a<br \/>DecodeDate\u4ece\u4e00\u4e2aTDateTime\u7c7b\u578b\u53c2\u6570Date\u4e2d\u5206\u89e3\u51fa\u5f97\u5230\u5e74\u4efd\u3001\u6708\u4efd\u3001\u65e5\u5b50\u3002<\/p>\n<p>\u25cfprocedure DecodeDateDay(const AValue: TDateTime; out AYear, ADayOfYear: Word);<\/p>\n<p>\u63cf\u8ff0\uff1a<br \/>DecodeDateDay \u65b9\u6cd5\u4f1a\u6839\u636eTDateTime\u7c7b\u578b\u53c2\u6570AValue \u5f97\u5230\u76f8\u5e94\u7684\u5e74\u4efd\u548c\u65e5\u671f\u603b\u6570\u3002<br \/>ADayOfYear\uff1a1\u67081\u65e5\uff0c\u6b64\u6570\u503c\u4e3a1\uff1b1\u67082\u65e5\uff0c\u6b64\u6570\u503c\u4e3a2\u3002<\/p>\n<p>\u25cfprocedure DecodeDateMonthWeek(const AValue: TDateTime; out AYear, AMonth, AWeekOfMonth, <\/p>\n<p>ADayOfWeek: Word);<\/p>\n<p>\u63cf\u8ff0\uff1a<br \/>DecodeDateMonthWeek\u65b9\u6cd5\u6839\u636eTDateTime\u7c7b\u578b\u53c2\u6570AValue \u5f97\u5230\u76f8\u5e94\u7684\u5e74\u4efd\u3001\u6708\u4efd\u3001\u6708\u4efd\u4e2d\u7684\u7b2c\u51e0\u4e2a<br \/>\u661f\u671f\u3001\u661f\u671f\u51e0<br \/>AYear\uff1a\u5e74\u4efd<br \/>AMonth\uff1a\u6708\u4efd\uff0c1 \u5230 12<br \/>AWeekOfMonth\uff1a\u5728\u8be5\u6708\u4efd\u4e2d\u7684\u7b2c\u51e0\u4e2a\u661f\u671f<br \/>ADayOfWeek\uff1a\u661f\u671f\u51e0\u3002\u661f\u671f\u4e00\u4e3a1\u3002<\/p>\n<p>\u25cfprocedure DecodeDateTime(const AValue: TDateTime; out AYear, AMonth, ADay, AHour, AMinute, <\/p>\n<p>ASecond, AMilliSecond: Word);<\/p>\n<p>\u63cf\u8ff0\uff1a<br \/>DecodeDateTime \u65b9\u6cd5\u6839\u636eTDateTime\u7c7b\u578b\u53c2\u6570AValue \u5f97\u5230\u76f8\u5e94\u7684\u5e74\u4efd\u3001\u6708\u4efd\u3001\u65e5\u5b50\u3001\u5c0f\u65f6\u3001\u5206\u3001\u79d2\u3001<br \/>\u6beb\u79d2\u3002<\/p>\n<p>\u25cfprocedure DecodeDateWeek(const AValue: TDateTime; out AYear, AWeekOfYear, ADayOfWeek: Word);<\/p>\n<p>\u63cf\u8ff0\uff1a<br \/>DecodeDateWeek\u65b9\u6cd5\u6839\u636eTDateTime\u7c7b\u578b\u53c2\u6570AValue \u5f97\u5230\u76f8\u5e94\u7684\u5e74\u4efd\u3001\u5728\u8be5\u5e74\u4e2d\u7684\u7b2c\u51e0\u4e2a\u661f\u671f\u3001\u661f\u671f\u51e0\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5e38\u7528\u65e5\u671f\u51fd\u6570\uff08delphi\uff09 Day \u5f00\u5934\u7684\u51fd\u6570\u25cfUnit DateUtils function DateOf [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-61","post","type-post","status-publish","format-standard","hentry","category-delphi"],"_links":{"self":[{"href":"https:\/\/www.kumouse.com\/index.php?rest_route=\/wp\/v2\/posts\/61","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kumouse.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kumouse.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kumouse.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kumouse.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=61"}],"version-history":[{"count":0,"href":"https:\/\/www.kumouse.com\/index.php?rest_route=\/wp\/v2\/posts\/61\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.kumouse.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=61"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kumouse.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=61"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kumouse.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=61"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}