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.

I think you were close. It’s the DateTimeOriginal EXIF field according to the code.

I don’t see that string in the code you linked to. Are you extrapolating it from here?

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

Sorry, Github doesn’t expand the code blocks linked in the URL. Here they are. Just below

lib/Listener/OriginalDateTimeMetadataProvider.php

		// Try to use EXIF data.
        if ($metadata->hasKey('photos-exif') && array_key_exists('DateTimeOriginal', $metadata->getArray('photos-exif'))) {
			$rawDateTimeOriginal = $metadata->getArray('photos-exif')['DateTimeOriginal'];
			$dateTimeOriginal = DateTime::createFromFormat("Y:m:d G:i:s", $rawDateTimeOriginal);
			$metadata->setInt('photos-original_date_time', $dateTimeOriginal->getTimestamp(), true);
			return;
		}