Groups | Blog | Home
all groups > dotnet internationalization > december 2006 >

dotnet internationalization : Changing the timezone for ASP.Net App



Victor Reboucas
12/19/2006 2:06:02 PM
Hi, I have a problem that I'm pretty sure is not an usual one

I have an asp.net app that's running in a server in Texas-US but I'm
operating the system in Brasil, this means that every time I have to deal
with the current date/time (now() function) I get the values from a timezone
that's different than the timezone the users are physically in.

I read about the system.timezone class but could not implement it the way I
want to, I mean, I was not able to "say to the system" "start operating in
GMT -3"


PS: I need to find a way to change the timezone used by the system per user
because just Brasil has 4 different timezones

PS2: In another system I've developed I implemented a solution using a value
stored in the app.config file with the number of hours I have to apply to
correct the current date/time. This kind of approach is kind of very poor
because I'm forced to operate in a single timezone and perform a lot of
calculations along the system, what get's me more work than solution to deal
with the problem

If some one have any clue...



Thanks a lot,
Victor

aldod NO[at]SPAM online.microsoft.com (
12/20/2006 1:23:26 AM
Hi Victor, I don't think it's an unusual scenario.
I think a good approach (same as the one Outlook Web Access uses) is to
profile your users and allow them to select a Timezone that gets stored
with it.
So when they get authenticated you already know how much to add/subtract to
the UTC-converted datetime. Of course this goes along with the
recommendation of converting/storing all of your datetimes on the server in
UTC format so it's easier to so add/subtract the delta. (delta is from UTC,
which is independednt of the location of your server)

HTH,
Aldo

-- This posting is provided "AS IS" with no warranties, and confers no
rights.


--------------------
| From: "Victor Reboucas" <vcreb@hotmail.com>
| Subject: Changing the timezone for ASP.Net App
| Date: Tue, 19 Dec 2006 14:06:02 -0300
|
| Hi, I have a problem that I'm pretty sure is not an usual one
|
| I have an asp.net app that's running in a server in Texas-US but I'm
| operating the system in Brasil, this means that every time I have to deal
| with the current date/time (now() function) I get the values from a
timezone
| that's different than the timezone the users are physically in.
|
| I read about the system.timezone class but could not implement it the way
I
| want to, I mean, I was not able to "say to the system" "start operating
in
| GMT -3"
|
|
| PS: I need to find a way to change the timezone used by the system per
user
| because just Brasil has 4 different timezones
|
| PS2: In another system I've developed I implemented a solution using a
value
| stored in the app.config file with the number of hours I have to apply to
| correct the current date/time. This kind of approach is kind of very poor
| because I'm forced to operate in a single timezone and perform a lot of
| calculations along the system, what get's me more work than solution to
deal
| with the problem
|
| If some one have any clue...
|
|
|
| Thanks a lot,
| Victor
|
|
|
Victor Reboucas
12/21/2006 12:24:09 PM
Ok, I can store the UTC per user, but, can I use the system.timezone to
correct the date/time or this object has nothing to do with ASP.Net
globalization process?

I mean, if you set the Culture or UICulture you get the ASP.Net
globalization features working, but, can I set a system.timezone parameter
for the Culture object to correct the dates?

All I don't want to do is to implement is all these calculations...

PS: I may be searching for a feature that does not exist (at least I did not
found it yet), but, since I started developing apps using .Net in version
1.0 there's a rule of thumb I always follow: "when a thing starts getting
too complicated (too much code for little tasks), study a little bit more
and you'll find a way to solve the problem using .Net itself" - I'm just not
sure if this rule applies here...


Thanks a lot,
Victor




[quoted text, click to view]

aldod NO[at]SPAM online.microsoft.com (
12/28/2006 3:14:11 AM
Hi Victor, I think you are out of luck in this case.

As you can see the BCL team has been asking for scenarios for
implementations of new methods in the TimeZone class
<http://blogs.msdn.com/bclteam/archive/2006/07/05/657242.aspx>

And they have started implementing TimeZone conversions for Orcas
<http://blogs.msdn.com/bclteam/archive/2006/10/03/System.TimeZone2-Starter-G
uide-_5B00_Kathy-Kam_5D00_.aspx>

But in your case you should not need that, because *roughly* you only need
(a) to convert .ToUniversalTime() when you store dates/times on the server
and (b) add to these dates/times the delta for each user before you display
them

A few more interesting articles
- DateTime structure + please notice the added comment and the link at the
bottom of the article
<http://msdn2.microsoft.com/en-us/library/system.datetime(VS.80).aspx>
- Webservices and Timezones
<http://blogs.msdn.com/suryaj/archive/2006/03/29/564322.aspx>

HTH
Aldo

-- This posting is provided "AS IS" with no warranties, and confers no
rights.


--------------------
| From: "Victor Reboucas" <vcreb@hotmail.com>
| References: <ua34ge4IHHA.3872@TK2MSFTNGP06.phx.gbl>
<YuN0zV9IHHA.2488@TK2MSFTNGHUB02.phx.gbl>
| Subject: Re: Changing the timezone for ASP.Net App
| Date: Thu, 21 Dec 2006 12:24:09 -0300
| Lines: 95
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.3028
| X-RFC2646: Format=Flowed; Original
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3028
| Message-ID: <#fmf8uQJHHA.4376@TK2MSFTNGP03.phx.gbl>
| Newsgroups: microsoft.public.dotnet.internationalization
| NNTP-Posting-Host: 200-168-83-152.dsl.telesp.net.br 200.168.83.152
| Path: TK2MSFTNGHUB02.phx.gbl!TK2MSFTNGP01.phx.gbl!TK2MSFTNGP03.phx.gbl
| Xref: TK2MSFTNGHUB02.phx.gbl
microsoft.public.dotnet.internationalization:52
| X-Tomcat-NG: microsoft.public.dotnet.internationalization
|
| Ok, I can store the UTC per user, but, can I use the system.timezone to
| correct the date/time or this object has nothing to do with ASP.Net
| globalization process?
|
| I mean, if you set the Culture or UICulture you get the ASP.Net
| globalization features working, but, can I set a system.timezone
parameter
| for the Culture object to correct the dates?
|
| All I don't want to do is to implement is all these calculations...
|
| PS: I may be searching for a feature that does not exist (at least I did
not
| found it yet), but, since I started developing apps using .Net in version
| 1.0 there's a rule of thumb I always follow: "when a thing starts getting
| too complicated (too much code for little tasks), study a little bit more
| and you'll find a way to solve the problem using .Net itself" - I'm just
not
| sure if this rule applies here...
|
|
| Thanks a lot,
| Victor
|
|
|
|
[quoted text, click to view]
| > Hi Victor, I don't think it's an unusual scenario.
| > I think a good approach (same as the one Outlook Web Access uses) is to
| > profile your users and allow them to select a Timezone that gets stored
| > with it.
| > So when they get authenticated you already know how much to
add/subtract
| > to
| > the UTC-converted datetime. Of course this goes along with the
| > recommendation of converting/storing all of your datetimes on the
server
| > in
| > UTC format so it's easier to so add/subtract the delta. (delta is from
| > UTC,
| > which is independednt of the location of your server)
| >
| > HTH,
| > Aldo
| >
| > -- This posting is provided "AS IS" with no warranties, and confers no
| > rights.
| >
| >
| > --------------------
| > | From: "Victor Reboucas" <vcreb@hotmail.com>
| > | Subject: Changing the timezone for ASP.Net App
| > | Date: Tue, 19 Dec 2006 14:06:02 -0300
| > |
| > | Hi, I have a problem that I'm pretty sure is not an usual one
| > |
| > | I have an asp.net app that's running in a server in Texas-US but I'm
| > | operating the system in Brasil, this means that every time I have to
| > deal
| > | with the current date/time (now() function) I get the values from a
| > timezone
| > | that's different than the timezone the users are physically in.
| > |
| > | I read about the system.timezone class but could not implement it the
| > way
| > I
| > | want to, I mean, I was not able to "say to the system" "start
operating
| > in
| > | GMT -3"
| > |
| > |
| > | PS: I need to find a way to change the timezone used by the system per
| > user
| > | because just Brasil has 4 different timezones
| > |
| > | PS2: In another system I've developed I implemented a solution using a
| > value
| > | stored in the app.config file with the number of hours I have to
apply
| > to
| > | correct the current date/time. This kind of approach is kind of very
| > poor
| > | because I'm forced to operate in a single timezone and perform a lot
of
| > | calculations along the system, what get's me more work than solution
to
| > deal
| > | with the problem
| > |
| > | If some one have any clue...
| > |
| > |
| > |
| > | Thanks a lot,
| > | Victor
| > |
| > |
| > |
| >
|
|
|
AddThis Social Bookmark Button