Using file mtime for the timestamp of new items

suso

Joined: 2006-12-14
Posts: 1
Posted: Thu, 2006-12-14 18:31

Hi,

I know this is probably a very particular need, and so it won't get into the official version, but perhaps it's useful for someone, so I post it here.

I like having my videos correctly timestamped, so they get sorted in the right position among the photos. As changing the timestamps in Gallery is slow for many videos, I thought it would be easier if Gallery just used the file modification time when importing them (I can very easily change the file mtime with a script, as I use the date for the filename). Of course this only applies to the "Local Server" import method, as any other would ignore the mtime.

If someone finds this useful, this is the simple modification you need:

* Edit modules/core/classes/GalleryDataItem.class
* Go to the end of the create() method, just after the call to setSize()
* Add these lines:

        /* Set the origination timestamp from the file mtime */
        $stat = $platform->stat($inputFileName);
        $this->setOriginationTimestamp($stat['mtime']);

As this is called before fetchOriginationTimestamp(), there's no problem with photos, they will still take the timestamp from EXIF data.

That's all!

Regards,
Suso