Where does the Memories app get a photo's date?

Where does the Memories app get a photo’s date to determine where to put it in the Timeline?

I moved some media to my NC server. Then I installed Memories and ran occ files:scan and memories:index. Many (but not all) photos are put on the date they were copied to the NC server.

I’ve not been able to figure out what the commonality is using EXIFTool. I used it to change a few date fields in a file, and then re-ran the occ commands, but the photo stubbornly remained on the wrong date.

So! I think the problem is either that I’m targeting the wrong EXIF fields, or that Memories uses something else to find dates.

Thanks!

https://memories.gallery/memories-vs-photos/ says: “Memories uses the EXIF data to get the Date Taken, providing for the correct sort order regardless if the files are edited / touched later.” But I don’t see a “Date Taken” EXIF tag on correctly ordered photos.

I think the code was added to Line 60 of files.js of this pull request: https://github.com/nextcloud/photos/commit/2340fc3a05fcc075e99bae4112234ec8683efbdb . Specifically:

const date = moment((file.metadataPhotosOriginalDateTime * 1000) || file.lastmod)

But I don’t know where that variable came from.