CreationDateTime, ModificationDateTime - Strange Problem

Hello everyone,

I have a very strange problem that only occurs with one customer. Another had the same thing a while ago, but it disappeared for no apparent reason.

My code modifies the ModificationDateTime and CreationDateTime of a file. The ModificationDateTime is always correct, but the CreationDateTime is always 23:26 min later than requested and expected.

Both times showed the same time shift when I used the deprecated ModificationDate and CreationDate properties. After switching to DateTime, only the CreationDateTime is invalid.

Any ideas are welcome.

This is a sample output from the code below.

Dim mdtPreviewModification As DateTime
Dim mdtPreviewCreation As DateTime
System.DebugLog "tfdat - 2. mdtPreviewModification:  " + mdtPreviewModification.SQLDateTime
System.DebugLog "tfdat - 2. mdtPreviewCreation:      " + mdtPreviewCreation.SQLDateTime

CellTag4(I) = mdtPreviewCreation.SQLDateTime
CellTag5(I) = mdtPreviewModification.SQLDateTime

fi.ModificationDateTime = DateTime.FromString(CellTag5(I))
fi.CreationDateTime = DateTime.FromString(CellTag4(I))

System.DebugLog "tfdat - 1. fi.ModificationDateTime: " + fi.ModificationDateTime.SQLDateTime
System.DebugLog "tfdat - 1. fi.CreationDateTime:     " + fi.CreationDateTime.SQLDateTime

Xojo version? I do remember complaints about differences on those values before.

The Xojo version is 2023 1.1. macOS is 13.4.1.

The two issues are different.

I and many other customers are not able to reproduce the erroneous time. It showed up on 2 systems only. On one of them it disappeared. So only one is left. Strange.

Here’s a sample project that uses declares for macOS:

To use it you’ll add _Fixed to the methods when retrieving the dates and use the SetDates method to set:

Var f as folderitem = ... whatever your file is ...

// Get the creation and modification dates
Var createDate as DateTime = f.CreationDateTime_Fixed
Var modDate as DateTime = f.ModificationDateTime_Fixed

// Set the dates
f.SetDates(modDate, createDate)

FWIW, the reason I went with a method to set both values is that setting the two values individually seems to cause one of the date changes to be ignored or corrupted on my machine. During testing of this project, I ended up with a file that was “modified” in 2069 even though I had specified 2022.

1 Like

Thank you Greg,

I will try this and of course I will look at your project tonight.

What does the _Fixed suffix do? I couldn’t find anything about it in the documentation. OK, I just looked into your code and found it. I first thought it’s a secret compiler property :wink:

But what makes it so strange for me is that I can’t see what in the environment is causing the problem.

I have the order of the two method calls reversed. So now the CreationDate is set before the ModificationDate. The problem occurs less often. But depending on what is done before, just still.

That’s just a suffix that I added to the methods I created. In the sample project, you’ll find a module called FolderItemExtensions which contains the new methods.

IIRC, there are some timezones which have fractional daylight savings offsets which don’t always convert correctly.

NOTE: This fix is only for macOS and iOS. My methods return the built-in values for Windows & Linux.

See my edited post. I finally got it.

Maybe, but the first customer who had this behaviour was here in Germany and his settings were correct. The other one is in Latvia and they have no fractional settings there as well. And why should it only happen with the CreationDate or with both dates if the calls are reversed?

Yes, I understood.

Thank you very much again!

After looking into your code I noticed that there is no way to set the time because there is no assignment code, which is what I need for this case. And I’m not familiar enough with declares for macOS.

Use the SetDates method, you’re passing in two DateTime objects.

I apologize. I’ve read this before and didn’t realize. So sorry.

Thank you, Greg,

Your code helped me a lot. The problem does not occur any more. I’m happy that my customer was so patient and I could test it with him.

Does the Xojo stuff know about these problems already?

There are bug reports about it already.