Question

I'm trying to make sense out of this on Lazarus Pascal

Note: dtWeekEnding is of type TDateEdit

ShowMessage( LongDayNames[DayOfTheWeek( dtWeekEnding.Date) ]);

My output expected is the name of the day for a given value in dtWeekEnding. But I have to issues:

  1. I get a warning that LongDayNames is deprecated. Then what should I use?
  2. The day name returned is incorrect. On the (drop down) calendar, it clearly shows the day but the message box is a day before it.

Am I missing something? Please advice.

Edit: For what it's worth, I tried this:

ShowMessage( LongDayNames[DayOfTheWeek( dtWeekEnding.Date) +1 ]); //Added 1 to the answer.

When I tried the above change, all days come out correctly BUT not Sunday. Sunday doesn't show at all. For example, selecting September 1st shows nothing as the name of the day.

Thanks!

Was it helpful?

Solution

  1. In later Delphis these settings moved to a TFormatsettings record called "FormatSettings". FPC had such construct for years, and deprecated the old ones (just like recent Delphi versions).

  2. This is dayofTHEweek() vs dayofweek() that have differing definitions of what the first day of the week is.

There was a note of this in the dayofweek help, but I now also added a reference from the help topic for short and longdaynames that will hopefully make this clearer (will be visible in the documentation of the next release)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top