473,473 Members | 1,900 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

TimeZones

I would like to set the timezone of a thread to allow me
to calculate the UTC time for data sourced from a number
of time zones. Although this can be done in C and C++, I
annot find how to do this is C#. Can this be done ? If
so how ?

Please note setting the culture does not impact the
timezone and a culture (like en-US) may have many
timezones.
Nov 15 '05 #1
13 6999
Hi Michael,

Thanks for posting.

Could you elaborate a little bit more on "data sourced from a number of
time zones"? Is it string data or the timestamps on the file?

In .Net, we have a structure "System.DateTime". It contains some members
("Parse", "ToUniversalTime", "FromFileTimeUtc" etc.) that may be helpful to
you:

http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfSystemDateTimeMembersTopic.asp?frame=true

In addition, there is also a class named "System.TimeZone":

http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfSystemTimeZoneClassTopic.asp?frame=true

Please check and see whether or not these help to achieve your goal.

Happy Thanksgiving!

Regards,

Felix Wang
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 15 '05 #2
You cannot do this with the current framework, and the TimeZone API is
really poor. You cannot enumerate available timezones, you cannot even
create a timezone with a given offset. All you can do is read the machine's
timezone, as it has been configured through the control panel, and convert
DateTime to UTC and back to the local timezone.

This is really insufficient. I have posted a request to enhance the timezone
API on the Whidbey beta newsgroup, asking specifically for the following
features:

* Enumerating timezones

* Associating a timezone to the current thread, the same way you can
associate a culture to the current thread, which is exactly what you suggest
(of course you can define your own ThreadStatic variable, but it won't have
any influence on the way DateTimes are formatted and parsed, so it is of
very little help, we need a framework level variable that works like
CultureInfo.CurrentCulture).

I would really like to see this feature in the next version of the
framework, but I feel that it won't make it unless more people complain
about the weakness of the current API (usually the .NET API is richer than
the Java API, but here is is much weaker). So, if you feel that the TimeZone
API is too weak, and if you want this feature in the next version of the
Framework, raise your voice.

Bruno.

"Michael" <mi*******@avanade.com> a écrit dans le message de
news:7c****************************@phx.gbl...
I would like to set the timezone of a thread to allow me
to calculate the UTC time for data sourced from a number
of time zones. Although this can be done in C and C++, I
annot find how to do this is C#. Can this be done ? If
so how ?

Please note setting the culture does not impact the
timezone and a culture (like en-US) may have many
timezones.

Nov 15 '05 #3
Hi Michael

Although not possible with the current API, there are several solutions for
Windows operating systems available. They all rely on the registry info for
timezones. Google on '.NET C# Timezone'.

Regards

Ron

"Michael" <mi*******@avanade.com> wrote in message
news:7c****************************@phx.gbl...
I would like to set the timezone of a thread to allow me
to calculate the UTC time for data sourced from a number
of time zones. Although this can be done in C and C++, I
annot find how to do this is C#. Can this be done ? If
so how ?

Please note setting the culture does not impact the
timezone and a culture (like en-US) may have many
timezones.

Nov 15 '05 #4
Come on Felix, why not just reply that .NET timezone support is rudimentary?
Bruno has summarised its failings.

Regards

Ron

"Felix Wang" <v-*****@online.microsoft.com> wrote in message
news:qp*************@cpmsftngxa06.phx.gbl...
Hi Michael,

Thanks for posting.

Could you elaborate a little bit more on "data sourced from a number of
time zones"? Is it string data or the timestamps on the file?

In .Net, we have a structure "System.DateTime". It contains some members
("Parse", "ToUniversalTime", "FromFileTimeUtc" etc.) that may be helpful to you:

http://msdn.microsoft.com/library/de...us/cpref/html/ frlrfSystemDateTimeMembersTopic.asp?frame=true

In addition, there is also a class named "System.TimeZone":

http://msdn.microsoft.com/library/de...us/cpref/html/ frlrfSystemTimeZoneClassTopic.asp?frame=true

Please check and see whether or not these help to achieve your goal.

Happy Thanksgiving!

Regards,

Felix Wang
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 15 '05 #5
Hello Bruno,

Although off topic where can I find the Whidbey Beta Group you referenced.
What is Whidbey?

I would very much like to see timezone handling in .Net also and have spent
a couple long nights tring to handle a users current time based on zone.
Specifically I was playing around with a web app that implemented satelite
assemblies with localization. The website adjusted the assembly bases on
the browser (default) or user specified setting of their culture. But when
I wanted to handle time with the users I ran into a huge mess tring to
figure it out. Especially when getting into daylight savings and other
details.

Where can I go to post this request along with yours? It would make things
much easier.
"Bruno Jouhier [MVP]" <bj******@club-internet.fr> wrote in message
news:OL**************@TK2MSFTNGP10.phx.gbl...
You cannot do this with the current framework, and the TimeZone API is
really poor. You cannot enumerate available timezones, you cannot even
create a timezone with a given offset. All you can do is read the machine's timezone, as it has been configured through the control panel, and convert
DateTime to UTC and back to the local timezone.

This is really insufficient. I have posted a request to enhance the timezone API on the Whidbey beta newsgroup, asking specifically for the following
features:

* Enumerating timezones

* Associating a timezone to the current thread, the same way you can
associate a culture to the current thread, which is exactly what you suggest (of course you can define your own ThreadStatic variable, but it won't have any influence on the way DateTimes are formatted and parsed, so it is of
very little help, we need a framework level variable that works like
CultureInfo.CurrentCulture).

I would really like to see this feature in the next version of the
framework, but I feel that it won't make it unless more people complain
about the weakness of the current API (usually the .NET API is richer than
the Java API, but here is is much weaker). So, if you feel that the TimeZone API is too weak, and if you want this feature in the next version of the
Framework, raise your voice.

Bruno.

"Michael" <mi*******@avanade.com> a écrit dans le message de
news:7c****************************@phx.gbl...
I would like to set the timezone of a thread to allow me
to calculate the UTC time for data sourced from a number
of time zones. Although this can be done in C and C++, I
annot find how to do this is C#. Can this be done ? If
so how ?

Please note setting the culture does not impact the
timezone and a culture (like en-US) may have many
timezones.


Nov 15 '05 #6
Felix,

The system "merges" data from a number of servers. The
servers are in different timezones. The data includes
datetime fields with the datetime in local format and not
stored as UTC time.
So the cultural differences can be handled be setting
"Thread.CurrentThread.CurrentCulture".

There is no timezone equivalent (I think we need
"Thread.CurrentThread.CurrentTimezone".

I can't really on a fixed offset as then daylight saving
light is not handled. The fix looks like writing a little
app to run on the soruce system and return the culture and
offset.

C and C++ offer tx handling and setting, C# should as well.

Michael.
-----Original Message-----
Come on Felix, why not just reply that .NET timezone support is rudimentary?Bruno has summarised its failings.

Regards

Ron

"Felix Wang" <v-*****@online.microsoft.com> wrote in messagenews:qp*************@cpmsftngxa06.phx.gbl...
Hi Michael,

Thanks for posting.

Could you elaborate a little bit more on "data sourced from a number of time zones"? Is it string data or the timestamps on the file?
In .Net, we have a structure "System.DateTime". It contains some members ("Parse", "ToUniversalTime", "FromFileTimeUtc" etc.) that may be helpful
to
you:

http://msdn.microsoft.com/library/default.asp?

url=/library/en-us/cpref/html/ frlrfSystemDateTimeMembersTopic.asp?frame=true

In addition, there is also a class named "System.TimeZone":

http://msdn.microsoft.com/library/default.asp?

url=/library/en-us/cpref/html/
frlrfSystemTimeZoneClassTopic.asp?frame=true

Please check and see whether or not these help to achieve your goal.
Happy Thanksgiving!

Regards,

Felix Wang
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

.

Nov 15 '05 #7
Hello Ron,

Whidbey is the code name for the next version of Visual Studio .NET. I'm
lucky enough to be enrolled in their beta program. The newsgroups are
private newsgroups reserved to beta testers. You should contact Microsoft if
you want to participate to the beta program.

Our web application has requirements similar to yours. We would like every
visitor to feel completely "at home", i.e. get a fully localized site with
messages in his language, and times formatted in his timezone. As the server
is multi-threaded, we need the ability to set a different TimeZone in every
thread.

I will repost on the Whidbey newsgroup, with a reference to this thread, to
try to catch the attention of the people who control what will go into the
next iteration of the framework.

Today, we use a workaround: we use the Java API to manipulate timezones. You
don't even need to program in J# to do it, you can do it in C# by adding a
reference to vjslib in your C# project. Then, you can use the Java TimeZone
class from the java.util namespace (note: it is buggy on NT4). This
workaround gives us access to a richer TimeZone API but is not fully
satisfactory because DateTime values are still formatted with the machine's
timezone, we have no way to set a thread-level variable that would influence
this.

Bruno.
"Ron Vecchi" <rv*****@xilehdvecchi.com> a écrit dans le message de
news:%2******************@TK2MSFTNGP10.phx.gbl...
Hello Bruno,

Although off topic where can I find the Whidbey Beta Group you referenced.
What is Whidbey?

I would very much like to see timezone handling in .Net also and have spent a couple long nights tring to handle a users current time based on zone.
Specifically I was playing around with a web app that implemented satelite
assemblies with localization. The website adjusted the assembly bases on
the browser (default) or user specified setting of their culture. But when I wanted to handle time with the users I ran into a huge mess tring to
figure it out. Especially when getting into daylight savings and other
details.

Where can I go to post this request along with yours? It would make things much easier.
"Bruno Jouhier [MVP]" <bj******@club-internet.fr> wrote in message
news:OL**************@TK2MSFTNGP10.phx.gbl...
You cannot do this with the current framework, and the TimeZone API is
really poor. You cannot enumerate available timezones, you cannot even
create a timezone with a given offset. All you can do is read the

machine's
timezone, as it has been configured through the control panel, and convert DateTime to UTC and back to the local timezone.

This is really insufficient. I have posted a request to enhance the

timezone
API on the Whidbey beta newsgroup, asking specifically for the following
features:

* Enumerating timezones

* Associating a timezone to the current thread, the same way you can
associate a culture to the current thread, which is exactly what you

suggest
(of course you can define your own ThreadStatic variable, but it won't

have
any influence on the way DateTimes are formatted and parsed, so it is of
very little help, we need a framework level variable that works like
CultureInfo.CurrentCulture).

I would really like to see this feature in the next version of the
framework, but I feel that it won't make it unless more people complain
about the weakness of the current API (usually the .NET API is richer than the Java API, but here is is much weaker). So, if you feel that the

TimeZone
API is too weak, and if you want this feature in the next version of the
Framework, raise your voice.

Bruno.

"Michael" <mi*******@avanade.com> a écrit dans le message de
news:7c****************************@phx.gbl...
I would like to set the timezone of a thread to allow me
to calculate the UTC time for data sourced from a number
of time zones. Although this can be done in C and C++, I
annot find how to do this is C#. Can this be done ? If
so how ?

Please note setting the culture does not impact the
timezone and a culture (like en-US) may have many
timezones.



Nov 15 '05 #8
Hi Ron,

Another way is to use the java.util.TimeZone class from the J# runtime, as I
mention in another response.

Bruno.
"Ron McNulty" <rm******@despam.xtra.co.nz> a écrit dans le message de
news:e3**************@TK2MSFTNGP11.phx.gbl...
Hi Michael

Although not possible with the current API, there are several solutions for Windows operating systems available. They all rely on the registry info for timezones. Google on '.NET C# Timezone'.

Regards

Ron

"Michael" <mi*******@avanade.com> wrote in message
news:7c****************************@phx.gbl...
I would like to set the timezone of a thread to allow me
to calculate the UTC time for data sourced from a number
of time zones. Although this can be done in C and C++, I
annot find how to do this is C#. Can this be done ? If
so how ?

Please note setting the culture does not impact the
timezone and a culture (like en-US) may have many
timezones.


Nov 15 '05 #9
> There is no timezone equivalent (I think we need
"Thread.CurrentThread.CurrentTimezone".


Yes, this is what we really need.

Bruno.
Nov 15 '05 #10
Hi Ron,
"Ron McNulty" <rm******@despam.xtra.co.nz> a écrit dans le message de
news:e3**************@TK2MSFTNGP11.phx.gbl...
Hi Michael

Although not possible with the current API, there are several solutions for Windows operating systems available. They all rely on the registry info for timezones. Google on '.NET C# Timezone'.

Regards

Ron

"Michael" <mi*******@avanade.com> wrote in message
news:7c****************************@phx.gbl...
I would like to set the timezone of a thread to allow me
to calculate the UTC time for data sourced from a number
of time zones. Although this can be done in C and C++, I
annot find how to do this is C#. Can this be done ? If
so how ?

Please note setting the culture does not impact the
timezone and a culture (like en-US) may have many
timezones.


Nov 15 '05 #11
Hi Michael,

I have to admit that the time zone support in the current .Net Framework is
not sufficient. It is very complicated to calculate daylight saving
time/periods among different areas and the rules are subject to changes.

I think the most convenient way to solve this may be to collect the UTC
time instead of local time from the servers.

Happy Thanksgiving!

Regards,

Felix Wang
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 15 '05 #12
Thanks Bruno,

Iam just getting ready to investigate the Java work around

"Bruno Jouhier [MVP]" <bj******@club-internet.fr> wrote in message
news:#A*************@TK2MSFTNGP11.phx.gbl...
Hello Ron,

Whidbey is the code name for the next version of Visual Studio .NET. I'm
lucky enough to be enrolled in their beta program. The newsgroups are
private newsgroups reserved to beta testers. You should contact Microsoft if you want to participate to the beta program.

Our web application has requirements similar to yours. We would like every
visitor to feel completely "at home", i.e. get a fully localized site with
messages in his language, and times formatted in his timezone. As the server is multi-threaded, we need the ability to set a different TimeZone in every thread.

I will repost on the Whidbey newsgroup, with a reference to this thread, to try to catch the attention of the people who control what will go into the
next iteration of the framework.

Today, we use a workaround: we use the Java API to manipulate timezones. You don't even need to program in J# to do it, you can do it in C# by adding a
reference to vjslib in your C# project. Then, you can use the Java TimeZone class from the java.util namespace (note: it is buggy on NT4). This
workaround gives us access to a richer TimeZone API but is not fully
satisfactory because DateTime values are still formatted with the machine's timezone, we have no way to set a thread-level variable that would influence this.

Bruno.
"Ron Vecchi" <rv*****@xilehdvecchi.com> a écrit dans le message de
news:%2******************@TK2MSFTNGP10.phx.gbl...
Hello Bruno,

Although off topic where can I find the Whidbey Beta Group you referenced.
What is Whidbey?

I would very much like to see timezone handling in .Net also and have

spent
a couple long nights tring to handle a users current time based on zone.
Specifically I was playing around with a web app that implemented satelite assemblies with localization. The website adjusted the assembly bases on the browser (default) or user specified setting of their culture. But

when
I wanted to handle time with the users I ran into a huge mess tring to
figure it out. Especially when getting into daylight savings and other
details.

Where can I go to post this request along with yours? It would make

things
much easier.
"Bruno Jouhier [MVP]" <bj******@club-internet.fr> wrote in message
news:OL**************@TK2MSFTNGP10.phx.gbl...
You cannot do this with the current framework, and the TimeZone API is
really poor. You cannot enumerate available timezones, you cannot even
create a timezone with a given offset. All you can do is read the

machine's
timezone, as it has been configured through the control panel, and

convert DateTime to UTC and back to the local timezone.

This is really insufficient. I have posted a request to enhance the

timezone
API on the Whidbey beta newsgroup, asking specifically for the following features:

* Enumerating timezones

* Associating a timezone to the current thread, the same way you can
associate a culture to the current thread, which is exactly what you

suggest
(of course you can define your own ThreadStatic variable, but it won't

have
any influence on the way DateTimes are formatted and parsed, so it is of very little help, we need a framework level variable that works like
CultureInfo.CurrentCulture).

I would really like to see this feature in the next version of the
framework, but I feel that it won't make it unless more people complain about the weakness of the current API (usually the .NET API is richer than the Java API, but here is is much weaker). So, if you feel that the

TimeZone
API is too weak, and if you want this feature in the next version of the Framework, raise your voice.

Bruno.

"Michael" <mi*******@avanade.com> a écrit dans le message de
news:7c****************************@phx.gbl...
> I would like to set the timezone of a thread to allow me
> to calculate the UTC time for data sourced from a number
> of time zones. Although this can be done in C and C++, I
> annot find how to do this is C#. Can this be done ? If
> so how ?
>
> Please note setting the culture does not impact the
> timezone and a culture (like en-US) may have many
> timezones.



Nov 15 '05 #13

I have written a component which supports time zone
and daylight saving time in .NET.
maybe this hint will helps you.

michael
www.sminformatik.de

Nov 15 '05 #14

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

Similar topics

0
by: B. G. Mahesh | last post by:
hi I am using PHP 4.x and MySQL. The database has the list of countries, cities and timezones. I would like to convert the time from one zone to another zone . It is not that difficult to...
0
by: Symon R | last post by:
This is a bit of a weird one that I haven't yet been able to solve - I'm hoping someone out there can disprove my findings and tell me where I've gone wrong! I have designed a web service that...
0
by: Robert Treat | last post by:
I am trying to figure out if there is a way to determine the timezones supported in postgresql from within the database. If you look at...
1
by: Flack | last post by:
Hey guys, I need to compare two times that the user selects. The user selects the hour, date, and timezone (which can be either NY, LN, or HK timezones). How can I compare two dates of...
5
by: Alex | last post by:
Hi My website is hosted in the States (EST), but the website itself is targeted for UK users (GMT). How can I offset the time so that the server reports it as GMT when my ASP.NET app needs to...
7
by: =?Utf-8?B?U3R1?= | last post by:
I have a ASP.NET Ajax app (using client library) calling ASP.NET Ajax-enabled web services. We are making use of the javascript proxies generated by ASP.NET Ajax. The problem we have is that the...
3
by: Daz | last post by:
Hello everyone. I am creating a JavaScript project which will allow users to see what time it is in other countries. I am wondering if there's any way to have the server work this out, without...
7
by: David T. Ashley | last post by:
In a web database (PHP), per user, I'd like to allow each user to specify their timezone (this would change how times are adjusted for display for that user). How do I enumerate all possible...
27
by: Sanjay | last post by:
Hi All, I am using pytz.common_timezones to populate the timezone combo box of some user registration form. But as it has so many timezones (around 400), it is a bit confusing to the users. Is...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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...

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.