Storing TimeZoneInfo in the database and using in Gui for .N

Posted by asthomas on 21-Nov-2011 07:19

Hi there,

A mixed schema dn GUI for  .Net question.

Are any of you using and storing the Infragistics.Win.TimeZoneInfo for datetime-tz data in your databases? If so, how are you storing this and the using it in your UI?

As the TimeZoneInfo is not part of the standard ABL timezone data - it looks like we have to store the timezoneinfo in a seprate field for every field in the database where we want to be able to use this. Or does someone else have an idea pon how to avoid this?

TIA

Regards

Thomas

All Replies

Posted by gus on 21-Nov-2011 13:05

What information is in the Infragistics.Win.TimeZoneInfo ?

Posted by asthomas on 21-Nov-2011 15:35

Hi Gus,

The timezone information that is displayed in the drop down list - very similar to the Microsoft TimeZoneInfo object.

As there can be several timezones with the same utc offset - it is not enough to be storing the offest (which is available from the datetime-tz datatype). I also want to store and display the correct timezone information´, either based on the users local settings (default if nothing is set) or the timezone info that the user selected when selecting the datetime-tz data.

Here's some info from InfraGistics:

http://help.infragistics.com/Help/NetAdvantage/WinForms/2011.1/CLR2.0/HTML/WinTimeZoneEditor_Interacting_with_TimeZoneInfo_Objects.html

I have managed to get this working by storing the StandardName property of the timezone in a separate field e.g. "Romance Standard Time" or "W. European Standard Time" - and then using this to set the UI correctly when data is retrieved from the database.

MS TimeZoneInfo has a nice TimeZoneInfo.ToSerializedString Method that can be used to store the object as text. Doesn't look like the IG has this - so you have to roll your own as far as I can determine.

Regards / Med Venlig Hilsen 

Thomas Hansen

Director

Posted by gus on 22-Nov-2011 10:25

As I understand it, you are interested in saving the string (e.g. "W. European Standard Time") that contains the name of the time zone because the values of type datetime-tz do not include it. Is that correct? Unfortunately, the names, while better than the three letter abbreviations, are somewhat unstable and subject to the vagaries of politicians. Calling British Standard Time for several years simply because the politicians didn't want to call it European for instance.

What will you do with the information? Or, to put the question another way, how will having this help you?

Posted by asthomas on 22-Nov-2011 10:55

Agreed it is not the best solution, as there seem to be variants in the names. The contents of the UI component we are using reads data from the registry - so this may also vary from machine to machine.

I need it to set the correct timezone on the UI in a control that shows both the datetime and the timezone info - not just the UTC offset. So it is purely for the UI that I need it.

Prior to this, I was using code to select the first timezone that had the correct UTC offset. If the user is in a timezone that is nt the first one - the UI is not going to show the correct timezone.

Regards / Med Venlig Hilsen 

Thomas Hansen

Director

Posted by Admin on 22-Nov-2011 11:07

How about adding a timezone master table to your database? Because you'll have to be able to display the records on those other PC's that may have a different timezone information in the registry?

You could use Infragistics/MS TimeZone enums to feed this master table initially. But I wouldn't rely on it for a longer duration, as Gus suggested.

Posted by asthomas on 22-Nov-2011 11:55

Good idea!

Regards / Med Venlig Hilsen 

Thomas Hansen

Director

Posted by gus on 22-Nov-2011 14:35

agree, a good idea. if you have systems that are not all Windows, you might also need a table that maps the names used in the UNIX/Linux/Java/ICU Olson timezone database. those are in the form region/city, such as Americas/New_York. I believe there is an implementation of it for .NET too, so you could perhaps use it instead of the Infragistics version.

Posted by asthomas on 22-Nov-2011 14:45

Cool - thanks for the info Gus. Will cterainly take it all into consideration.

Regards / Med Venlig Hilsen 

Thomas Hansen

Director

This thread is closed