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 / .NET SDK / October 2006

Tip: Looking for answers? Try searching our database.

DateTime, TimeZone, AAARRRRRGGGGGGGGHHHHHHHH!

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
David Thielen - 27 Oct 2006 00:51 GMT
Hi;

Ok, I'm going nuts here. We have a scheduler in our ASP.NET app and here are
a couple of major problems I am hitting.

1) Someone schedules an item to run weekdays at 1:00 am - Colorado time. The
server is in Japan so it's the next day there for local server time. Or the
local & server could be such that it is a different day UTC time.

The easy approach seems to be that I set the scheduled time to run next in
UTC - but I save the time of day to run in the timezone of the request and do
my calculations of the next run in the requesters time zone so I am working
in the datetime that will be correct for IsWeekday, etc.

Here's the problem - how can I get a DateTime for a timezone that is not UTC
and not server local? Those seem to be the only two choices.

2) Based on a user's Culture - how do I determine what days are the weekend?
GetDayOfWeek returns a 0 for Sunday regardless of culture. But the weekend in
the Middle East is Friday/Saturday while it's Saturday/Sunday everywhere else
(I think).

3) Based on a user's culture, how do I find out the first day of the week?
In the US it's Sunday while I believe in Europe it's Monday. And who knows
what elsewhere.

4) Where can I get the localized (by culture) names for months of the year
and days of the month?

Signature

thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm

Steven Cheng[MSFT] - 27 Oct 2006 09:27 GMT
Hello Dave,

As for the DateTime and TimeZone issue, I think it will be hard to
completely handled through the .net framework interfaces. Yes, you're
limited to current timezone and UTC time when using the Datetime functions
to manipulate DateTime instances.

For your scenario, is it posible that you always converted DateTime to a
consistent timezone(of the server's local timezone) before store them in
system. And all the calculation will based on only one timezone?

For get datetime of non-local or UTC zone, so far there is no built-in
support in .net framework. What we  can do is get the timezone offset (you
can find some information in your another several posts) and do the
calculation to get other timezone's datetime.

For your following questions:

=======================
2) Based on a user's Culture - how do I determine what days are the
weekend?
GetDayOfWeek returns a 0 for Sunday regardless of culture. But the weekend
in
the Middle East is Friday/Saturday while it's Saturday/Sunday everywhere
else
(I think).

3) Based on a user's culture, how do I find out the first day of the week?
In the US it's Sunday while I believe in Europe it's Monday. And who knows
what elsewhere.
========================

So far I haven't got any good ideas, I can help you ask some other
globaldev engineers to see whether there is any means through win32
platform API. The .net encapsulated interfaces are all under the
System.Globalization namespace(especially the XXXCalender class).

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.

==================================================



This posting is provided "AS IS" with no warranties, and confers no rights.
David Thielen - 27 Oct 2006 16:17 GMT
ok - thanks.

It still astounds me how incomplete I18N support is to this day.

Signature

thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm

> Hello Dave,
>
[quoted text clipped - 66 lines]
>
> This posting is provided "AS IS" with no warranties, and confers no rights.
David Thielen - 27 Oct 2006 16:18 GMT
Hi again;

Any idea on:
4) Where can I get the localized (by culture) names for months of the year
and days of the month?

Signature

thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm

David Thielen - 27 Oct 2006 16:23 GMT
Found this one - DateTimeFormatInfo

Signature

thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm

> Hi again;
>
> Any idea on:
> 4) Where can I get the localized (by culture) names for months of the year
> and days of the month?
Steven Cheng[MSFT] - 30 Oct 2006 11:00 GMT
Thanks for your reply Dave,

I've consult some other globaldev engineers and here are some further
information:

The following two posts have the explanation of what can be returned about
weeks and weekends what cannot, and why

http://blogs.msdn.com/michkap/archive/2006/08/24/710624.aspx
http://blogs.msdn.com/michkap/archive/2005/09/20/471605.aspx

here is the original comments from them:
===================
As for the Gregorian localized names, they are only available when you have
the appropriate UI language installed; other calendars that have their own
day names will sometimes find themselves already localized within the
calendar.

In other words, most of this info is not generically available to any
application....
====================

Hope this helps further.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

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

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.