473,785 Members | 2,938 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Timezone and time API problem (.net bug!?)

I have the following code for a clock in my gui.

Everything works fine EXCEPT the following line when the TimeZone is changed
in the windows.

string tz = TimeZone.Curren tTimeZone.Stand ardName;

It will not pick the changed timezone

but it does pick up time change due to timezone change.

Should it not update the timezone each time the timer ticks? the time does.

However, if i restart the application the new timezone is picked up.

BTW Anyone have a better way to format the time? :) sorry i am noob

private void ClockTimer_Tick (object sender, EventArgs e)

{

int hour=DateTime.N ow.Hour;

int min=DateTime.No w.Minute;

int sec=DateTime.No w.Second;
string TimeInString =(hour < 10)?"0" + hour.ToString() :hour.ToString( );

TimeInString+=" :" + ((min<10)?"0" + min.ToString() :min.ToString() );

TimeInString+=" :" + ((sec<10)?"0" + sec.ToString() :sec.ToString() );
string tz = TimeZone.Curren tTimeZone.Stand ardName;

string[] temp = tz.Split(' ');

if(temp.Length >=3)

lblClock.Text = TimeInString + " " +temp[0][0] + temp[1][0] + temp[2][0];

else

lblClock.Text = TimeInString;

}
Nov 17 '05 #1
1 2554

"Raj Chudasama" wrote...
Everything works fine EXCEPT the following line when
the TimeZone is changed in the windows.

string tz = TimeZone.Curren tTimeZone.Stand ardName;

It will not pick the changed timezone

but it does pick up time change due to timezone change.

Should it not update the timezone each time the timer ticks? the time
does.


They are two different classes (TimeZone and DateTime), so you can't
extrapolate the behaviour from DateTime to TimeZone.

My guess is that the value behind the static property CurrentTimeZone is
defined as a static variable itself, and assigned "at first use" of TimeZone
in your application.

// Bjorn A
Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
3205
by: Jim Davis | last post by:
I'm (still) working on an ISO 8601 date parser. I want to convert at least the formats described here: http://www.w3.org/TR/NOTE-datetime Well.. I've got most of it working (via RegEx's) good enough for me but I'm having a brain block when it comes to TimeZone. The datetime may come with an optional timezone offset (from GMT) as here (the offset is +1 hour from GMT):
1
4032
by: cnliou | last post by:
Hi! If I correctly understand v7.4 manual, value, say, '2003-11-26 12:00' in TIMESTAMP WITHOUT TIMEZONE column should output '2003-11-26 19:00' for "+08:00" timezone. The following test results seem to be somewhat unexpected. Restting OS timezone (/etc/timezone and /etc/localtime in Linux) does not make the results more comfortable.
0
1908
by: Todd Bandrowsky | last post by:
I'm fixing a generic TimeZone class in C# for a server application. If I derive from TimeZone and implement a GetDaylightChanges method that returns the same data as Microsoft's TimeZone, and also implement a GetUtcOffset that further returns the same data Microsoft's TimeZone, then why wouldn't using TimeZone's ToLocalTime and ToUniversalTime work?
6
2481
by: Bijoy Naick | last post by:
I have an events table which stores the time of each event - the time and assoicated timezone. Is there a way of converting this time into GMT (with support for DST).. some sort of function which accepts a time and timezone as parameters and returns the time in GMT?
13
2872
by: Bruno Wolff III | last post by:
Recently there has been some discussion about attaching a timezone to a timestamp and some other discussion about including a 'day' part in the interval type. These two features impact each other, since if you add a 'day' to a timestamp the result can depend on what timezone the timestamp is supposed to be in. It probably makes more sense to use a timezone associated with the timestamp than say the timezone GUC or the fixed timezone UTC. ...
18
12115
by: newbie | last post by:
Hi, I wonder if it's possible to detect a user (the browser's) timezone when he/she access my php file? I saw ppl suggesting using javascript to collect that information. But I wonder if it's possible to do it without the headache of javascript. Thanks,
2
11875
by: Sanjay | last post by:
Hi All, Using pytz, I am facing a problem with Asia/Calcutta, described below. Asia/Calcutta is actually IST, which is GMT + 5:30. But while using pytz, it was recognized as HMT (GMT + 5:53). While I digged into the oslan database, I see the following: # Zone NAME GMTOFF RULES FORMAT Zone Asia/Calcutta 5:53:28 - LMT 1880 # Kolkata
2
3687
by: =?Utf-8?B?Sm9ubnk=?= | last post by:
I have an ASP.NET 2.0 C# web application that is contacting an Exchange server using WEBDAV. It allows the users to look up appointments for a future date. The problem I have is determining the correct client time zone. Note that Exchange stores everything in UTC time. I am able currently able to use javascript to ask the client what time zone they are in, but this is only for the "today" (the current day) and not for a day in the...
6
20327
by: jehugaleahsa | last post by:
Hello: I would like it so that the time displayed was always for CDT/CDS. Potentially, the application can be run at locations in Mountain Time or Central Time. This is what I have now: // get the UTC offset depending on day light savings double hourOffset = DateTime.Now.IsDaylightSavingTime() ? -5 : -6; DateTimeOffset offset = DateTimeOffset.UtcNow.ToOffset(TimeSpan.FromHours(hourOffset));
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10153
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9952
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7500
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6740
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5381
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4053
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2880
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.