In my application (Silverlight client - server - SQL Server DB) with SQL Server as a back end I need to make various calculations and display times in various time zones. I need to make calculations on both client, server and DB sides.
This is application where I need various time zones at the same time, it's not typical "Local vs UTC" All data will be stored in UTC format but I will need to make conversions to: 1. Location time 2. User's time
So, let's say if we talking air travel - I will store times in UTC but user will see them in departure/arrival time zones.
I'm looking for best practices and maybe correct me if I'm wrong on how I'm going to approach it:
- Database will have "TimeZones" table with info like Time zone name, id, time offset and is this zone observes DST
- Users and locations in database will be linked to TimeZone
- On client and server (.NET) I'm going to load TimeZones table and cache it inside my shared DateTimeService. This way I will be able to bind UI when needed and do all conversions I need in one central place
- Calculations on UI/server will be done with .NET's built-in
DateTime
&TimeZoneInfo
functionality
What bothers me is that I will have to do 2 different sets of functionality on SQL Server and .NET for converting. I don't want CLR code in SQL Server. Most likely I will have manually coded time conversion functions in T-SQL and I will have TimeZoneInfo doing work for me on .NET side.
Also, I will have to do FK everywhere in DB where I reference TImeZOne table. That will cause other problems like constantly joining, etc.
How do you manage this kind of information in your databases and applications?