The System.DateUtils unit in Delphi provides various functions for working with dates and times. Here is an example of how you can use some of the functions from the System.DateUtils unit:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
uses System.DateUtils; var Today, Tomorrow: TDateTime; begin Today := Date; WriteLn(‘Today is ‘, DateToStr(Today)); Tomorrow = IncDay(Today, 1); WriteLn(‘Tomorrow is ‘, DateToStr(Tomorrow)); if IsToday(Tomorrow) then WriteLn(‘Tomorrow is today!’) else WriteLn(‘Tomorrow is not today.’); if IsInLeapYear(Today) then WriteLn(‘Today is in a leap year.’) else WriteLn(‘Today is not in a leap year.’); end. |
In this example, we are using the following functions from the System.DateUtils unit:
- Date returns the current date.
- IncDay increments a date by a given number of days.
- IsToday checks if a given date is today.
- IsInLeapYear checks if a given date is in a leap year.
We are also using the DateToStr function from the System unit to convert a TDateTime value to a string.
Leave a Reply