I am trying to find a way to get MP3Tag to convert a date/time text string (of the format: YYYY-MM-DD HH:MM:SS) into the Unix Epoch time format that MP3Tag uses for its 'raw' dates.
As a very inexperienced user, I am pleased that I managed to entirely create my own solution for converting MP3Tag's raw epoch time format into 18-digit LDAP / Win32 FILETIME (which is used by Foobar2000's music library). I searched for absolutely ages to find a formula for how to convert between the two (almost all of the search results were for programming code and didn't explain the actual calculation needed).
Eventually I found a calculation, and I constructed this in MP3Tag:
$add($mul(%_file_mod_datetime_raw%,10000000),116444736000000000)
It works great, and it means that I can set my music library's 'First Added' date based on the timestamp of the file (instead of whatever arbitrary date the database just so happened to encounter the track for the first time). Also, the dates don't all get lost if you restore the database from a backup (you can just re-import them from the timestamps in the 'First Added' tags).
However, this is still a bit limiting because the timestamp on the file doesn't always correspond to when I added it to my music library, therefore I'd like to be able to manually type a date string into a tag, and have that converted to the relevant format tag for my music library's database.
Seeing as I've already worked out how to get from MP3Tag's raw Unix Epoch time to LDAP / Win32 Filetime, I can use the exact same method for my own dates. The issue that I am stuck on though is how to calculate Unix Epoch time for a specified date (which is needed as part of my calculation).
Searching for a calculation for this was even worse than the Win32 < > Epoch conversion, but after a couple of hours I think I have found one.
What I need help with is how to strip all non-numeric characters from the YYYY-MM-DD HH:MM:SS date string (dashes, space, and colons) and then use the component parts of the resulting numeric sting (year, month, day etc.) in the calculation below. The output of this calculation would then take the place of %_file_mod_datetime_raw% used in the action that I create above.
Of course I only need to do this assuming that MP3Tag doesn't have an existing way to display a user-specified date as 'Raw'. But the only options that I have seen are for 'created' and 'modified' file dates to be displayed as raw, not user-specified dates.
tm_sec + tm_min*60 + tm_hour*3600 + tm_yday*86400 +
(tm_year-70)*31536000 + ((tm_year-69)/4)*86400 -
((tm_year-1)/100)*86400 + ((tm_year+299)/400)*86400
tm_sec = seconds
tm_min = minutes
tm_hour = hours
tm_yday = days since January 1 of the year ()
tm_year = calendar year minus 1900
Source: c++ - Math to convert seconds since 1970 into date and vice versa - Stack Overflow
The idea is to end up with a raw numeric representation of the specified date/time which I can then plug-in to my formula to convert it into LDAP / Win32 file time that my music library recognizes.
Any help would be greatly appreciated.
Thanks.