Possible issue with DateTime

I’m using the following code to populate a TList list…

method MonthSummaryView.tableView(tableView: UITableView) numberOfRowsInSection(section: NSInteger): NSInteger;
var
  ICount: Integer;
begin
  {$WARNING Potentially incomplete method implementation.}
  // Return the number of rows in the section.
  result := 0;
  if FMonth > 0 then
  begin
    result := DaysInMonth(EncodeDate(FYear, FMonth, 1));
    FDaysInMonth.Clear;
    for ICount := 1 to result do
      FDaysInMonth.Add(new DateTime(FYear, FMonth, ICount));
  end;
end;

I then use this list in the cellForRowAtIndexPath method to add the dates to the table view rows…

method MonthSummaryView.tableView(tableView: UITableView) cellForRowAtIndexPath(indexPath: NSIndexPath): UITableViewCell;
begin
var CellIdentifier := “MonthSummaryCell”;

result := tableView.dequeueReusableCellWithIdentifier(CellIdentifier);
if not assigned(result) then begin
result := new UITableViewCell withStyle(UITableViewCellStyle.UITableViewCellStyleDefault) reuseIdentifier(CellIdentifier);

// Configure the new cell, if necessary...

end;
result.textLabel.text := FDaysInMonth[indexPath.row].ToLongPrettyDateString;
// Configure the individual cell…
end;

However, my first row is always the last date of the previous month, rather than the first day of the month I am interested in.

I will run some standalone tests but I thought I’d let you know in case this was a bug… I can’t see anything wrong with my code which would cause the date to be out by 1 day.

I will keep playing with it here to see if I can track down the issue.

are you using Delphi RTL?

Yes, using a TList from DelphiRTL with a datetime type (not TDatetime)

Is it because I’m mixing delphi and delphi rtl types?

Think there may have been an issue with the FormatDateTime when using ‘dddd’ which wasn’t displaying the day name so I chose to use datetime instead.

Will be back at the pc later so will continue to test.

No. just establishing context. Delphi RTL is Diego’s baby, so i’ll asked him to have a look…

ok cool, what I saw with FormatDateTime() was that ‘DDDD’ was being formated as (for today) “0024” when I would have expected it to be format as “Monday”

Again, maybe it’s something I’ve done wrong in my code as still very new here but thought I’d mention it in case it was a bug.