In fleet management the tracker moves across timezones and stores its position with a timestamp which is always UTC. This is good, because it has to stick with one timezone. Otherwise it could have two different positions with the same timestamp if it changes timezones (i.e. for daylight saving time).
If the fleet manager uses my software to look at the data, he wants to see the time in his local timezone, even if he sees mixed up timestamps (he will know why).
To achieve this I store them as UTC times in the database and convert them to local times whem they are displayed. I use:
DateTime.SpecifyKind(date, dateTimeKind)
DateTime.ToUniversalTime()
DateTime.ToLocalTime()
So everybody should be as happy as a clam at high water, but some tables are set as DataSource for a DataGridView (Windows.System.Forms.DataGridView.DataSource = System.Data.DataTable)
. This is not bad per se, but I have no idea how to put a conversion in between.
I'd be glad if I could use the DataGridViewCellStyle
.Format property to indicate the timezone to show, but as far as I understand this is not an option. Right now in some tables both times are stored in the database, so the user decides which time to show/hide, but this is a real pain in the arse if you have to double every DateTime
column in the database and put a show/hide functionality next to it.
Which way do you propose? I've read about the RowCreatedEvent
(here), but I am not building an web application.