I’m trying to build an interface between iTunes and MediaMonkeys. When I imported my tracks from iTunes to MM, the field LastPlayed wasn’t considered.
So I decided to build an interface that reads the value from iTunes and updates the MM database.
I’m using the package from phxsoftware in order to access the SQLite database used by MM.
The database field is a REAL data type, which is mapped as DbType.Single. When I do the update, I’m converting a DateTime object (provided by IITTrack) to Single, using Convert.ToSingle(DateTime).
But I’m receiving an error, telling that Invalid cast from 'DateTime' to 'Single'.
Any hints about this?
According to http://www.mediamonkey.com/wiki/index.php/ISDBSongData::LastPlayed you need to do following:
LastPlayed.Subtract(new DateTime(1899, 12, 30, 0, 0, 0, DateTimeKind.Utc)).TotalDays;
It’s actually better to move that constant date to some static readonly value…
P.S. Comment that SQLite doesn’t differs integers and floats is WRONG – it has only 2 numeric types – 8-bytes floats and 8-bytes integers.