Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Internationalization / December 2006

Tip: Looking for answers? Try searching our database.

Changing the timezone for ASP.Net App

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Victor Reboucas - 19 Dec 2006 16:11 GMT
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
Aldo Donetti [MS] - 20 Dec 2006 01:23 GMT
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
[quoted text clipped - 25 lines]
| Thanks a lot,
| Victor
Victor Reboucas - 21 Dec 2006 14:27 GMT
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

> 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
[quoted text clipped - 55 lines]
> | Thanks a lot,
> | Victor
Aldo Donetti [MS] - 28 Dec 2006 03:14 GMT
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
[quoted text clipped - 9 lines]
| 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
|
[quoted text clipped - 77 lines]
| > | Thanks a lot,
| > | Victor

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.