Weird CultureInfo - DateTime.Parse() and Decimal.Parse()

  • Thread starter Thread starter Rico
  • Start date Start date
R

Rico

Hello Everyone,

I observed something strange in some quick testing code:

void Button1Click(object sender, System.EventArgs e)
{
CultureInfo culture = new CultureInfo("th-TH", false);

tbxDisplayResult.Text = DateTime.Parse(tbxInputArea.Text,
culture).ToString("yyyy MMMMMMMMMM dd");
}


with tbxInputArea.Text of "10.9.2006",
tbxDisplayResult.Text is displayed as "1463 September 10".

Thailand might have taken huge steps backwards over the past 24 hours, but
I doubt it's steps of that magnitude, isn't it?

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

void Button1Click(object sender, System.EventArgs e)
{
CultureInfo culture = new CultureInfo("ms-MY", false);

tbxDisplayResult.Text = Decimal.Parse(tbxInputArea.Text,
culture).ToString("N2");
}

tbxInputArea.Text of "1,973.00" results in a parsing error,
whereas with tbxInputArea.Text of "1.973,00" parsing succeeds.

I doubt that Malaysia uses decimal separators the way the Germans do.
Is that a bug in the framework?

Rico.
 
I doubt that Malaysia uses decimal separators the way the Germans do.
Is that a bug in the framework?

Rico.

You doubt they use decimal separators the wat the Germans do or you know
they don't? How come you call this a bug in the framework when you don't
even know the facts? How about looking at Regional and Language options in
control panel at Malay number format? They indeed use the decimal separators
the way the Germans do. Even if you doubt it.
 
The results are correct, you're just not interpreting them correctly. See
inline

Rico said:
Hello Everyone,

I observed something strange in some quick testing code:

void Button1Click(object sender, System.EventArgs e)
{
CultureInfo culture = new CultureInfo("th-TH", false);

tbxDisplayResult.Text = DateTime.Parse(tbxInputArea.Text,
culture).ToString("yyyy MMMMMMMMMM dd");
}


with tbxInputArea.Text of "10.9.2006",
tbxDisplayResult.Text is displayed as "1463 September 10".

Thailand might have taken huge steps backwards over the past 24 hours, but
I doubt it's steps of that magnitude, isn't it?

For starters your input data is incorrect. Thailand uses '/' as date
separator. Secondly, Parse actually succeedes here (even though you feed it
with invalid data). What you failed to realize is that Thailand uses a
calendar that is offset by 543 years, so Sept 10, 2006 in the Thai calendar
is the same as Sept 10, 1463 in the Gregorian calendar.

void Button1Click(object sender, System.EventArgs e)
{
CultureInfo culture = new CultureInfo("ms-MY", false);

tbxDisplayResult.Text = Decimal.Parse(tbxInputArea.Text,
culture).ToString("N2");
}

tbxInputArea.Text of "1,973.00" results in a parsing error,
whereas with tbxInputArea.Text of "1.973,00" parsing succeeds.

I doubt that Malaysia uses decimal separators the way the Germans do.

Stop doubting and look it up instead (they do in fact use ',' as decimal
seprator).
Is that a bug in the framework?

No

/claes
 
Lebesgue said:
You doubt they use decimal separators the wat the Germans do or you
know they don't? How come you call this a bug in the framework when
you don't even know the facts? How about looking at Regional and
Language options in control panel at Malay number format? They indeed
use the decimal separators the way the Germans do. Even if you doubt
it.

Does it make you feel good to put me down dude?
Does it satisfy some psychological need of yours to make yourself aware of
how smart you are by virtue of your information gathering skills?

Some information gathering skills to be proud of.. control panel... heh..

I had thought before come here that it was a better idea to ask my friend
who lives and works in Malaysia how things go there, wouldn't you?
My friend's answer was that "1,973.00" was the way they wrote it.

I didn't come here saying that I have found a bug. The answer to the
question I asked seems to be that it's not a bug but just Microsoft
following the 'official' format, even though it's not the only one, or the
most commonly used one on a daily basis.

I could end by giving you the finger and saying "screw you!".. but I won't.
Thank you.

Rico.
 
The results are correct, you're just not interpreting them correctly.
See inline

ok.. I'm very much ready to realise and accept that.
For starters your input data is incorrect. Thailand uses '/' as date
separator. Secondly, Parse actually succeedes here (even though you
feed it with invalid data). What you failed to realize is that
Thailand uses a calendar that is offset by 543 years, so Sept 10, 2006
in the Thai calendar is the same as Sept 10, 1463 in the Gregorian
calendar.

Thanks. I had not thought about that.
Stop doubting and look it up instead (they do in fact use ',' as
decimal seprator).

I said "Malaysia" , not the Malay number format.

In fact, "1,973.00" is the format coming to us from a big-name enterprise
software and they claim that the decimal separators used are as per
expected in the corresponding country, in this case, Malaysia.
But CultureInfo for "ms-MY", says Malay(Malaysia) so the behaviour is
fine.

Thanks. Simple question, simple answer. I appreciate that.

Rico.
 
tbxInputArea.Text of "1,973.00" results in a parsing error,
I said "Malaysia" , not the Malay number format.

In fact, "1,973.00" is the format coming to us from a big-name enterprise
software and they claim that the decimal separators used are as per
expected in the corresponding country, in this case, Malaysia.
But CultureInfo for "ms-MY", says Malay(Malaysia) so the behaviour is
fine.

Hmm, this is strange. The culture info says decimal separator is comma.
Microsoft's NLS page says the same thing (not surprisingly);
http://www.microsoft.com/globaldev/nlsweb/default.mspx?submitted=043E&OS=Windows XP Service Pack 2

Wikipedia says dot is used;
http://en.wikipedia.org/wiki/Decimal_point

I found a bunch of other sources that also says dot is used (but most of
them seem to get their info from wikipedia)

The Malaysian Tourist Board (http://www.tourism.gov.my) uses dot as a
decimal separator (see the Currency section at
http://www.tourism.gov.my/en/essentials/default.asp)

I couldn't find an official Malaysian statement about it though. Maybe there
is an official standard that Microsoft uses, but everyone else uses
something different (which would make the standard pretty useless)

/claes
 
Claes Bergefall said:
Hmm, this is strange. The culture info says decimal separator is
comma. Microsoft's NLS page says the same thing (not surprisingly);
http://www.microsoft.com/globaldev/nlsweb/default.mspx?submitted=043E&O
S=Windows%20XP%20Service%20Pack%202

Wikipedia says dot is used;
http://en.wikipedia.org/wiki/Decimal_point

I found a bunch of other sources that also says dot is used (but most
of them seem to get their info from wikipedia)

The Malaysian Tourist Board (http://www.tourism.gov.my) uses dot as a
decimal separator (see the Currency section at
http://www.tourism.gov.my/en/essentials/default.asp)

I couldn't find an official Malaysian statement about it though. Maybe
there is an official standard that Microsoft uses, but everyone else
uses something different (which would make the standard pretty
useless)

You should teach our friend Lebesgue a lesson or two about information
gathering skills. Not only does he have the gall to blast an 8yr neighbour
of Malaysia for mentioning the word 'bug' and doubting his beloved
framework while not *even* knowing the facts.. but he further proudly
relies on the *gasp* Control Panel as an alternate source to confirm what
the .Net framework says (as though not both are from Microsoft) .. Control
Panel.. heh..

Rico.
 
Oh. My. God. I've got a single question for you. Are you over 13 years old?
Better for you if you are not. Your mental skills are somewhere around that
level.
 
Oh. My. God. I've got a single question for you. Are you over 13 years old?
Better for you if you are not. Your mental skills are somewhere around that
level.

Yes.. You most definitely know that fact, and rightly so, of course..

Did the "Control Panel" tell you that?

Just like the "Control Panel" told you that :
[Malaysians] indeed use the decimal separators the way the Germans do.
Even if doubt it.


hehe...

Rico.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top