TimeZoneInfo

  • Thread starter Thread starter Mike Gleason jr Couturier
  • Start date Start date
M

Mike Gleason jr Couturier

Hi,

I'm working with the TimeZoneInfo class.

I'm storing all dates in the database in the UTC form.

To convert back the UTC to the user's timezone,
do I have to ask the user if he observes DST or
the TimeZoneInfo class will figure it out automagically?

Thanks
 
Hi,

just convert it to the local time using
..ToLocalTime()
when you want it back

Regards
Arijit Chatterjee
 
Hi,

just convert it to the local time using
..ToLocalTime()
when you want it back

Regards
Arijit Chatterjee
 
Hi,

just convert it to the local time using
.ToLocalTime()
when you want it back

Regards
Arijit Chatterjee

It will convert a date to the server time, which can be different with
user's timezone.
 
Hi,

just convert it to the local time using
.ToLocalTime()
when you want it back

Regards
Arijit Chatterjee

It will convert a date to the server time, which can be different with
user's timezone.
 
Hi,

I'm working with the TimeZoneInfo class.

I'm storing all dates in the database in the UTC form.

To convert back the UTC to the user's timezone,
do I have to ask the user if he observes DST or
the TimeZoneInfo class will figure it out automagically?

Thanks

Mike,

you would need to find what time zone user needs. You can do it by
using a dropdown list with a list of all available time zones where
user can choose one as a default settings, or you can try to get it
automatically using a javascript, then from that you can display the
clients time based on that value. Here is a link on how to do it:

http://rsanidad.wordpress.com/2007/09/21/getting-the-client-utc-offset-with-aspnet/

Hope this helps
 
Hi,

I'm working with the TimeZoneInfo class.

I'm storing all dates in the database in the UTC form.

To convert back the UTC to the user's timezone,
do I have to ask the user if he observes DST or
the TimeZoneInfo class will figure it out automagically?

Thanks

Mike,

you would need to find what time zone user needs. You can do it by
using a dropdown list with a list of all available time zones where
user can choose one as a default settings, or you can try to get it
automatically using a javascript, then from that you can display the
clients time based on that value. Here is a link on how to do it:

http://rsanidad.wordpress.com/2007/09/21/getting-the-client-utc-offset-with-aspnet/

Hope this helps
 
Hi,

Thanks, I'm already doing that... sorry I wasn't clear!

In addition of the dropdown, do I need to add a checkbox to ask the user
whether or not he observes DST?

Maybe I try to make it harder than it really is!
 
Hi,

Thanks, I'm already doing that... sorry I wasn't clear!

In addition of the dropdown, do I need to add a checkbox to ask the user
whether or not he observes DST?

Maybe I try to make it harder than it really is!
 
If you have the user's postal code, or city/state, etc., you can store the
DST information in a database and check it. In general, just converting to
localized time will catch some of them, but there are counties that do not
observe, so it is not 100%. By knowing some information about the user you
can be more accurate.

Now the question you have to ask is where the app is being used and how
accurate you need to be. If accurate, either ask, or buy a good zip code
database that has the information (if US, although there are postal code
databases for other countries).

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*************************************************
| Think outside the box! |
*************************************************
 
If you have the user's postal code, or city/state, etc., you can store the
DST information in a database and check it. In general, just converting to
localized time will catch some of them, but there are counties that do not
observe, so it is not 100%. By knowing some information about the user you
can be more accurate.

Now the question you have to ask is where the app is being used and how
accurate you need to be. If accurate, either ask, or buy a good zip code
database that has the information (if US, although there are postal code
databases for other countries).

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*************************************************
| Think outside the box! |
*************************************************
 
Cowboy (Gregory A. Beamer) said:
If you have the user's postal code, or city/state, etc., you can store the
DST information in a database and check it. In general, just converting to
localized time will catch some of them, but there are counties that do not
observe, so it is not 100%. By knowing some information about the user you
can be more accurate.

Now the question you have to ask is where the app is being used and how
accurate you need to be. If accurate, either ask, or buy a good zip code
database that has the information (if US, although there are postal code
databases for other countries).

Hi, thanks for taking the time!

I already stored the users timezone (via TimeZoneInfo.GetSystemTimezones or
something) in the database.

I'm confused with the DST thingy. Some site will ask me if I observe DST. Do
I have to ask the user if he observes DST when I ask him its timezone?

Thanks
 
Cowboy (Gregory A. Beamer) said:
If you have the user's postal code, or city/state, etc., you can store the
DST information in a database and check it. In general, just converting to
localized time will catch some of them, but there are counties that do not
observe, so it is not 100%. By knowing some information about the user you
can be more accurate.

Now the question you have to ask is where the app is being used and how
accurate you need to be. If accurate, either ask, or buy a good zip code
database that has the information (if US, although there are postal code
databases for other countries).

Hi, thanks for taking the time!

I already stored the users timezone (via TimeZoneInfo.GetSystemTimezones or
something) in the database.

I'm confused with the DST thingy. Some site will ask me if I observe DST. Do
I have to ask the user if he observes DST when I ask him its timezone?

Thanks
 
Mike Gleason jr Couturier said:
I'm confused with the DST thingy. Some site will ask me if I observe DST.
Do I have to ask the user if he observes DST when I ask him its timezone?

For some time zones, the answer is no, as the entire time zone either
respects DST or not. You get into issues both with the Mountain Time Zone,
however. Arizona, for example, does not use DST, except the Navajo
reservation. This means you are generally safe to say NO to DST in Arizona,
unless your customer is on the Navajo nation. Hawaii, Puerto Rico, Virgin
Islands and American Samoa do not observe DST either.

Until 2005, you had an issue with Indiana, as some counties observed DST and
others did not. It was actually more complex than that, but we can roll with
this explanation. This is no longer the case, so you are safe stating
Central time always observes.

In Mexico, the state of Sonora does not observe DST, so you are safe to say
Mexico = yes, except Sonora.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*************************************************
| Think outside the box! |
*************************************************
 
Mike Gleason jr Couturier said:
I'm confused with the DST thingy. Some site will ask me if I observe DST.
Do I have to ask the user if he observes DST when I ask him its timezone?

For some time zones, the answer is no, as the entire time zone either
respects DST or not. You get into issues both with the Mountain Time Zone,
however. Arizona, for example, does not use DST, except the Navajo
reservation. This means you are generally safe to say NO to DST in Arizona,
unless your customer is on the Navajo nation. Hawaii, Puerto Rico, Virgin
Islands and American Samoa do not observe DST either.

Until 2005, you had an issue with Indiana, as some counties observed DST and
others did not. It was actually more complex than that, but we can roll with
this explanation. This is no longer the case, so you are safe stating
Central time always observes.

In Mexico, the state of Sonora does not observe DST, so you are safe to say
Mexico = yes, except Sonora.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*************************************************
| Think outside the box! |
*************************************************
 
Ok thanks.. Last question.

If a user is in a Timezone observing DST and in a region where they don't
follow their timezone by not observing DST, is there always a fallback he
can use to have the proper time?

It seems "a lot" of work supporting DST exceptions. I think I'll remove the
boolean (ObserveDST) from my objects. Also, this is confusing for some,
especially if they forgot to check "I want to observe DST" when registering.

Thanks
 
Ok thanks.. Last question.

If a user is in a Timezone observing DST and in a region where they don't
follow their timezone by not observing DST, is there always a fallback he
can use to have the proper time?

It seems "a lot" of work supporting DST exceptions. I think I'll remove the
boolean (ObserveDST) from my objects. Also, this is confusing for some,
especially if they forgot to check "I want to observe DST" when registering.

Thanks
 
Mike Gleason jr Couturier said:
Ok thanks.. Last question.

If a user is in a Timezone observing DST and in a region where they don't
follow their timezone by not observing DST, is there always a fallback he
can use to have the proper time?

It seems "a lot" of work supporting DST exceptions. I think I'll remove
the boolean (ObserveDST) from my objects. Also, this is confusing for
some, especially if they forgot to check "I want to observe DST" when
registering.

It is not that much work if you buy the database.

But, the best way is to ask the user if he wants to support DST in his sign
up, and give him the ability to change the answer later. Then a user in
Arizona that wants Moroccan time can have Moroccan time, with or without
DST. If they then call and complain it is Moroccan time, tell them "you
chose it, you can change it".

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

Blog: http://gregorybeamer.spaces.live.com
Twitter: @gbworld

*************************************************
| Think outside the box! |
*************************************************
 
Mike Gleason jr Couturier said:
Ok thanks.. Last question.

If a user is in a Timezone observing DST and in a region where they don't
follow their timezone by not observing DST, is there always a fallback he
can use to have the proper time?

It seems "a lot" of work supporting DST exceptions. I think I'll remove
the boolean (ObserveDST) from my objects. Also, this is confusing for
some, especially if they forgot to check "I want to observe DST" when
registering.

It is not that much work if you buy the database.

But, the best way is to ask the user if he wants to support DST in his sign
up, and give him the ability to change the answer later. Then a user in
Arizona that wants Moroccan time can have Moroccan time, with or without
DST. If they then call and complain it is Moroccan time, tell them "you
chose it, you can change it".

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

Blog: http://gregorybeamer.spaces.live.com
Twitter: @gbworld

*************************************************
| Think outside the box! |
*************************************************
 
Back
Top