So I updated to MySql.Data 8.0.13 and I noticed that my TIMESTAMP fields come as DateTimeKind.Local and the DATETIME fields are read as DateTimeKind.Unspecified
I thought that "Timestamp" would be a great semantic type to represent a "CreatedTime" field, so I went with it.
The thing is, I usually write these dates "manually" in the insert queries, they're generated by the application, in UTC, to make sure that local time and their crazy timezones/daylight savings won't break anything. I don't use on-update or on-insert on them. And now I'm getting problems with the application's JSON serializer converting an already UTC time to UTC again, which causes a wrong offset time.
So my question:
Is there a way to enforce MySQL.Data to "Consider those dates/timestamps as being UTC"? Or is it best for me to discontinue the usage of TIMESTAMP and adhere to DATETIME instead?
Or should I pull a crazy gimmick like this?
if(databaseValue is DateTime dt) {
databaseValue = new DateTime(dt.Ticks, DateTimeKind.UTC);
}
Which would be the preferable way to solve this problem?
DateTimeKindspecified by the dbms and consider it as always having been UTC. "If this date isn't UTC then it was saved wrong", I'm sure many could see heresy in what I'm going to do, but life is easier in UTC.