Everybody's working for the weekend

by Michael S. Kaplan, published on 2006/08/24 03:01 -04:00, original URI: http://blogs.msdn.com/b/michkap/archive/2006/08/24/710624.aspx


Peter asks:

My customer is programming with .NET.

Now he wanted to know if there is a way to determine if a given day in a Calendar is a weekend based on certain culture.

It is “Friday/Saturday” in the Middle East, “Saturday/Sunday” in Europe/Americas and probably something else in somewhere else.

We are trying to find a method similar as IsWeekend(Date d).

Based on my research, this code below will get the first day of week based on the culture.

    CultureInfo myCI = new CultureInfo("en-US");
    MessageBox.Show(myCI.DateTimeFormat.FirstDayOfWeek.ToString());

Is there a similar method for the information about weekend?

Thanks!

Hmmm. Not exactly the same question as the one asked in How many days in a weekend?, but close. And I did hypothesize back in that post from almost a year ago that the weekend was always in LOCALE_SDAYNAME6 and LOCALE_SDAYNAME7. But several people have pointed out that it ain't always so (there are indeed places that consider Sunday to be the first day of the week but Saturday/Sunday to the weekend.

So there really is no way in Windows or the .NET Framework to find out when the weekend is, per locale/culture.

What do you expect from a company with developers who think that working a half day means putting in 12 hours? :-)

 

This post brought to you by (U+24e6, a.k.a. CIRCLED LATIN SMALL LETTER W)


# Eric Duran on 25 Aug 2006 6:12 PM:

michkap wrote:
(there are indeed places that consider Sunday to be the first day of the week but Saturday/Sunday to the weekend.

Isn't the USA such a place like that? AFAIK, Sunday is the first day of the week and Saturday/Sunday are weekend days for locale en-US. Other places would be the southern-most state of the USA, namely Mexico, since we have followed the USA's lead in many regards.
Europeans can't help themselves to avoid bashing us for having such a "weird" thing as Sunday=first day of the week.

Besides, as you have pointed out, the definition of "weekend" is very subjective... for some fellow students, the weekend starts on Thursday, regardless of their current locale... :D

Please consider a donation to keep this archive running, maintained and free of advertising.
Donate €20 or more to receive an offline copy of the whole archive including all images.

go to newer or older post, or back to index or month or day