How to get name of month

P

prosoft

When I use
Dim myDTFI As DateTimeFormatInfo = New CultureInfo("he-IL",
True).DateTimeFormat
Dim strhmon1 As String = (myDTFI.GetMonthName(hmon1))
MsgBox(strhmon1)

I get the local name of the gregorian month.
How do I get the local name of the local month ?

Tia
 
J

Jared

Your code worked fine for me.
'Condensed version
Dim c As New CultureInfo("he-IL")
MessageBox.Show(c.DateTimeFormat.GetMonthName(Now.Month))
 
P

prosoft

I am getting the wrong information, is it a bug?

Dim tstHCal As New HebrewCalendar
Dim tstDT As New DateTime(2004, 9, 1) ' 1 sep' 2004
Dim hmonth As Integer = myHCal.GetMonth(tstDT)
Dim tstDTFI As DateTimeFormatInfo = New CultureInfo("he-IL",
True).DateTimeFormat
tstDTFI.Calendar = myHCal
Dim hmonthName As String = (tstDTFI.GetMonthName(hmonth))
MsgBox(hmonthName)

the output is "Av"
it should be "Elul" because 1 sep' 2004 is in "elul" , see hebcal.com
I can see what is happening as well. Usually month 12 (as in Gregorian
2004,9,1)
is "elul" , but when there is a leap year month 12 is "av" and month 13 is
"elul".
The problem is that
Dim hmonthName As String = (tstDTFI.GetMonthName(hmonth))
has no way of knowing if it's a leap year or not, so it always returns
a value as if it was a leap year. Is it supposed to be this way?
 
H

Herfried K. Wagner [MVP]

* "Jared said:
Your code worked fine for me.
'Condensed version
Dim c As New CultureInfo("he-IL")
MessageBox.Show(c.DateTimeFormat.GetMonthName(Now.Month))

I get something I am not able to read and translate to Roman letters
:).
 
J

Jared

You're right, I too get something; I don't know if it's correct, the method
didn't fail, good enough for me.
 
P

prosoft

I am not sure if you saw my post just below your reply, the timestamp
on it is 15:35. I explained that

Dim hmonthName As String = (tstDTFI.GetMonthName(hmonth))

cannot return the correct name because within this expression
there is no TimeDate information. I was just wondering why
GetMonthName was not included in the DateTime object,
perhaps I am doing something wrong... It's not a bug, maybee
a design bug, but not an implementation bug.

B.t.w. if you want to see hebrew text you need to add the
hebrew keyboard in the control panel, it's as easy as 1,2,3.


Jared said:
You're right, I too get something; I don't know if it's correct, the method
didn't fail, good enough for me.
 
H

Herfried K. Wagner [MVP]

* "Jared said:
You're right, I too get something; I don't know if it's correct, the method
didn't fail, good enough for me.

OK, the same for me.
 
C

Cor Ligthert

Prosoft,

I gave you an answer earlier than any other? What is wrong with that, when I
do it like this I get it even in what I think is Herbrew (??????)

Me.Textbox1.text = Now.ToString("MMMM", New
System.Globalization.CultureInfo("he-IL"))
Cor
 
H

Herfried K. Wagner [MVP]

Cor Ligthert said:
I sand it in this case as HTML, maybe your Hamster does not see that.

Really weird. gnus can deal with posts in HTML format normally...

On my machine, I get a different result:

??????

(I hope this will be posted correctly in text/plain format.)
 
H

Herfried K. Wagner [MVP]

OK, that didn't work. Next turn:

??????

Which is actually the same as Cor posted.

It's interesting that there are other characters showing up in the
messagebox than those that get posted when being copied into a message using
OE.
 
P

prosoft

did you get
????
or something else ?

Jared said:
Your code worked fine for me.
'Condensed version
Dim c As New CultureInfo("he-IL")
MessageBox.Show(c.DateTimeFormat.GetMonthName(Now.Month))
 
P

prosoft

Well done, your hebrew is working correctly, but what you are
getting from the code is 'September' written in hebrew, however,
there is another month you need to get called ????
This is the hebrew lunar month presently. Can you get it?

??????
 
P

prosoft

nope, you need to install the hebrew keyboard if you want to
read/write hebrew. It only works on win2000/xp i.e. not win98/me
 
P

prosoft

leta start again

Well done, your hebrew is working correctly, but what you are
getting from the code is 'September' written in hebrew, however,
there is another month you need to get called ×לול
which is the hebrew lunar month presently. Can you get it?
 

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

Top