I’m trying to display the creation date of the file, which is available as $img.CreationTime which returns the time as two 32 bit parts of one 64 bit integer - how do I combine these in order to display them as a proper date? I’ve searched around and can’t find any solutions that work, the ones that I’ve seen use a binary reader but I can’t seem to get one working properly.
I have looked and played around with the time package but could not figure out how to solve the problem since CreationTime is the 64 bit timestamp split into two 32 bit values which have to ‘glued’ before they can be parsed. Could you give me a tip on how that is supposed to be done?
The way I’ve seen this done is through the use of binary.Reader which is, to my knowledge and some testing, unavailable in Hugo.
Your OS assumption is correct I am on Windows.
Your solution also works, almost, using {{ $img.CreationTime.Nanoseconds }} → {{ $img.CreationTime.Nanoseconds | time }} results in 1610919232422978000 → 51048000281-11-05 03:20:00 +0100 CET.
Using https://www.epochconverter.com/ to convert 1610919232422978000 to local time gives the correct creation date of the file, but piping it into time seems to not work correctly. I’ve looked around in the time package and can’t find a function which takes nanoseconds and returns a readable date.
I tried to use time.Unix 0 <nanoseconds> but I get ... can't evaluate field Unix in type interface {}
Ideally I’d want to get the ‘Date taken’ property (see image below), since that is somewhat closer to the actual date of when the photo was taken (I take analogue photographs so in this case, Date taken is actually the day the image was developed and scanned, not when it was taken), but I don’t think that’s possible given that I currently store my images inside the static folder.