473,396 Members | 1,770 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

DateTime.DayOfWeek is not localized, why?

M
Hello,

I have code like
dt.DayOfWeek.ToString(CultureInfo.CurrentCulture)
where dt is a DateTime object.

I get something like "Sunday", "Monday", etc... while I'm expecting it to be
in French. I have a bilingual app in English and French. I don't have any
problem elsewhere, like when outputting the month for example, but DayOfWeek
is not working as I expected.

Any help is appreciated.

Thanks.
Nov 16 '05 #1
4 15747
RCS
CultureInfo.CurrentUICulture gets it runtime versus compile time. Are you
compiling on an english machine and running it on a french machine??

Also, I'd try dumping out the cultures (.GetCultures()) to make sure .NET
recognizes what you think it does..

HTH

"M" <so******@somewhere.com> wrote in message
news:e7**************@TK2MSFTNGP10.phx.gbl...
Hello,

I have code like
dt.DayOfWeek.ToString(CultureInfo.CurrentCulture)
where dt is a DateTime object.

I get something like "Sunday", "Monday", etc... while I'm expecting it to
be in French. I have a bilingual app in English and French. I don't have
any problem elsewhere, like when outputting the month for example, but
DayOfWeek is not working as I expected.

Any help is appreciated.

Thanks.

Nov 16 '05 #2
> CultureInfo.CurrentUICulture gets it runtime versus compile time. Are you
compiling on an english machine and running it on a french machine??

Also, I'd try dumping out the cultures (.GetCultures()) to make sure .NET
recognizes what you think it does..

CurrentCulture and CurrentUICulture depend only on the system running the
application, not on the system you compiling it.
Otherwise good advices.

--
Mihai Nita [Microsoft MVP, Windows - SDK]
------------------------------------------
Replace _year_ with _ to get the real email
Nov 16 '05 #3
"Mihai N." <nm**************@yahoo.com> wrote in
news:Xn********************@207.46.248.16:
CultureInfo.CurrentUICulture gets it runtime versus compile time. Are you
compiling on an english machine and running it on a french machine??

Also, I'd try dumping out the cultures (.GetCultures()) to make sure .NET
recognizes what you think it does..

CurrentCulture and CurrentUICulture depend only on the system running the
application, not on the system you compiling it.
Otherwise good advices.


Oups! I was not carefull enough!
dt.ToString("dddd", CultureInfo.CurrentCulture.DateTimeFormat);
should do.

CurrentCulture matches the user locale and the CurrentUICulture matches
the OS/MUI language.

This is unless you manualy change
System.Threading.Thread.CurrentThread.CurrentCultu re or
System.Threading.Thread.CurrentThread.CurrentUICul ture

--
Mihai Nita [Microsoft MVP, Windows - SDK]
------------------------------------------
Replace _year_ with _ to get the real email
Nov 16 '05 #4
M,
In addition to the other comments.

DateTime.DayOfWeek returns an enum, enums unfortunately are not localized.

http://msdn.microsoft.com/library/de...classtopic.asp

Fortunately! You should be able to use a custom date format of either "ddd"
(abbreviated) or "dddd" (full) to get localized day names:

dt.ToString("dddd")

For details on custom datetime formats see:

http://msdn.microsoft.com/library/de...matstrings.asp

For information on formatting in .NET in general see:
http://msdn.microsoft.com/library/de...ttingtypes.asp

Hope this helps
Jay
"M" <so******@somewhere.com> wrote in message
news:e7**************@TK2MSFTNGP10.phx.gbl...
Hello,

I have code like
dt.DayOfWeek.ToString(CultureInfo.CurrentCulture)
where dt is a DateTime object.

I get something like "Sunday", "Monday", etc... while I'm expecting it to
be in French. I have a bilingual app in English and French. I don't have
any problem elsewhere, like when outputting the month for example, but
DayOfWeek is not working as I expected.

Any help is appreciated.

Thanks.

Nov 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Gary Brewer | last post by:
Why did Microsoft decide to start the DateTime.DayOfWeek enumeration with Sunday and ending on Saturday. I thought that a week began on Monday rather than Sunday? Or is this an age old unresolved...
14
by: | last post by:
Hi! I will get the date from now (DateTime.Now is 18.12.2003) but exact 16 years ago (18.12.1987). when I make something like this: //we set min. employee age to 16 years TimeSpan...
3
by: Gerben van Loon | last post by:
Hi there, hope someone can help me on this: DateTime.Now.DayOfWeek is always returning the american day names like "Monday, Saturday". Even when my CurrentCulture is set to my localized culture....
2
by: Simple Simon | last post by:
Hi all, I'm struggling with an elegant way to figure out if a DateTime falls between any Firday @ 6pm and Sunday @ 9pm. For example: If i want to fax a message b/w Fri 6pm and Sun 9pm on any...
7
by: .Net Sports | last post by:
Before processing my data in a datagrid, I need to parse the day of the week (which will be my 'rqsday' variable) from a string that comes over on a querystring: string rqs =...
8
by: simon | last post by:
dateTime sellDate; int16 dayOfWeek; dayOfWeek=sellDate.DayOfWeek I would like to set that monday is the first day of a week and not sunday. Any idea? In VB there is a function, where you...
5
by: What-a-Tool | last post by:
Have a group of dynamically created text boxes in a calendar like grid. At the head of each column, the textbox is to contain the day of the week. Now I am using a Select Case statement to...
2
by: Paulers | last post by:
Hello Is it possible to create a DateTime structure that does not include the date? I am only intrested in the time and day. for example 23:00 Mon. I would eventually like to add and subtract...
2
by: David P. Donahue | last post by:
Probably a simple question: I have a function that receives as an argument a DateTime value. One of the things I want to do is check to see if it's a weekday. So I do the following (sorry for...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.