.NETGURU
How to get name of month
Messages   Related Types
This message was discovered on microsoft.public.dotnet.languages.vb.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
Post a new message to this list...

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

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

"prosoft" <ifyouneedmyemailpleaseask> wrote in message
news:evIL5p$Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
Herfried K. Wagner [MVP] (VIP)
* "Jared" <Click here to reveal e-mail address> scripsit:
[Original message clipped]

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

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Reply to this message...
 
    
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.

"Herfried K. Wagner [MVP]" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
Herfried K. Wagner [MVP] (VIP)
* "Jared" <@Click here to reveal e-mail address> scripsit:
[Original message clipped]

OK, the same for me.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Reply to this message...
 
    
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" <@Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
> You're right, I too get something; I don't know if it's correct, the
method
[Original message clipped]

Reply to this message...
 
    
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

[Original message clipped]

Reply to this message...
 
    
Cor Ligthert
ספטמבר
Reply to this message...
 
    
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?

"Cor Ligthert" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
??????

Reply to this message...
 
    
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?

Reply to this message...
 
    
Cor Ligthert
Prosoft,

I do not know the Hebrewic calender so I took, "Now" you can change with any
date.

Cor

Reply to this message...
 
    
Herfried K. Wagner [MVP] (VIP)
* "Cor Ligthert" <Click here to reveal e-mail address> scripsit:
[Original message clipped]

Huh!

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Reply to this message...
 
    
Cor Ligthert
[Original message clipped]


Reply to this message...
 
    
Herfried K. Wagner [MVP] (VIP)
"Cor Ligthert" <Click here to reveal e-mail address> schrieb:
[Original message clipped]

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.)

--
Herfried K. Wagner [Microsoft MVP]
<URL:http://dotnet.mvps.org/>

Reply to this message...
 
    
Herfried K. Wagner [MVP] (VIP)
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.

--
Herfried K. Wagner [Microsoft MVP]
<URL:http://dotnet.mvps.org/>

Reply to this message...
 
    
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

"Herfried K. Wagner [MVP]" <Click here to reveal e-mail address> wrote in message
news:eD8Z%Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
Herfried K. Wagner [MVP] (VIP)
* "prosoft" <ifyouneedmyemailpleaseask> scripsit:
[Original message clipped]

I have a German language system and I tried the code you and Jared
posted, and I see the output in hebrew. So it seems that the necessary
characters are available on my machine (Unicode). I copied the text and
pasted it into an OE message, but even in Unicode mode they didn't get
posted. BTW: I am using Windows XP Professional SP1.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Reply to this message...
 
    
prosoft
You need to set the mime, see my reply in this thread
timestamped 17:50

"Herfried K. Wagner [MVP]" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
prosoft
did you get
????
or something else ?

"Jared" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
Jared
I received ??????

"prosoft" <ifyouneedmyemailpleaseask> wrote in message
news:%Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
prosoft
O.k.
I have just realised that you need to set in Outlook Express in the 'send'
tab to use 'mime' . You will know you are sending hebrew unicode
when you click the 'send' button if a popup window will ask you if you
want to send as 'unicode' or not.

Counting the number of question marks in the word you obtained,
you are getting what Cor is getting, which is ספטמבר . This is simply
September written in hebrew. It is not the current *hebrew* month,
which is at present אלול

"Jared" <@Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
Cor Ligthert
Prosoft.
Now.ToString("MMMM")

I hope this helps?

Cor

"prosoft" <ifyouneedmyemailpleaseask> schreef in bericht
news:evIL5p$Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
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?

Reply to this message...
 
    
Jay B. Harlow [MVP - Outlook] (VIP)
Proof,
The way I understand it is

"prosoft" <ifyouneedmyemailpleaseask> wrote in message
news:Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
Jay B. Harlow [MVP - Outlook] (VIP)
Prosoft,
Lets try this again:

I think the problem is that HebrewCalendar does not consider 1 Sept 2004
(Gregorian) a Hebrew leap year. It does consider 1 Sept 2003 (Gregorian) a
Hebrew leap year.

To see what years it considered leap years I used:

Dim hebrewCalendar As New HebrewCalendar

For gregorianYear As Integer = 2000 To 2010
Dim sept09 As New DateTime(gregorianYear, 9, 1)
Dim hebrewYear As Integer = hebrewCalendar.GetYear(sept09)
Debug.WriteLine(hebrewCalendar.IsLeapYear(hebrewYear),
gregorianYear.ToString())
Next

I don't know enough about the Hebrew calendar to say whether or not
HebrewCalendar.IsLeapYear is returning the correct value or not. I don't see
anything in the Microsoft Knowledge Base.

I tested the above on .NET 1.1 without SP1.

Based on the above I could see where GetMonth returns different names trying
your code with:

[Original message clipped]

If you haven't you may also want to ask in the
microsoft.public.dotnet.internationalization newsgroup.

Hope this helps
Jay

"prosoft" <ifyouneedmyemailpleaseask> wrote in message
news:Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
prosoft
No, the problem is that

GetMonthName(x as integer)

always returns the same thing if x doesn't change.

But with

dim y as integer = myHebrewCalendar.GetMonth(someDateTime)

y can vary by 1 if y>6 because of the leap year,

so, for example, for the last hebrew month אלול y as above will
sometimes be assigned the value
y=12
and sometimes
y=13

Do you see?

This means we must test for a leap year before using

GetMonthName(x as integer)

otherwise we will get the wrong month name.

"Jay B. Harlow [MVP - Outlook]" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
Jay B. Harlow [MVP - Outlook] (VIP)
Prosoft,
Did you try asking in microsoft.public.dotnet.internationalization
newsgroup?

As it appears you are the Hebrew Calendar expert in this newsgroup. :-|

[Original message clipped]

No! I would expect GetMonthName to always return the same thing if x doesn't
change! As DateTimeFormatInfo has no concept of what the date (year in this
case) is, nor should it.

If GetMonthName varies because of year, then I would expect year to be a
parameter to GetMonthName. Just like the Calendar.IsLeapMonth function.
Actually I'm surprised that DateTimeFormatInfo functions expect integers
instead of DateTime objects. However that may be an attempt to decouple
something...

I'm curious as to what VS.NET 2005 (Whidbey, due out in 2005) offers to
simplify this...

Again if you haven't I strongly suggest
microsoft.public.dotnet.internationalization newsgroup, as I would hope that
group has more people that actively work with Hebrew & other calendars.

Hope this helps
Jay

"prosoft" <ifyouneedmyemailpleaseask> wrote in message
news:%Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
prosoft
"Jay B. Harlow [MVP - Outlook]" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
[Original message clipped]

Ha Ha, talk about decoupling..., this is precisely what I am asking/saying
i.e., why is GetMonthName not part of DateTime or why does
DateTimeFormatInfo accept integers and DateTime object, this is it!!!!!!!!
I might just re-ask the question in

microsoft.public.dotnet.internationalization

Thanks.

[Original message clipped]

Reply to this message...
 
    
Jay B. Harlow [MVP - Outlook] (VIP)
prosoft,
[Original message clipped]

Was that a rhetorical question? :-)

As I stated I would expect DateTimeFormatInfo.GetMonthName to either accept
a DateTime object, or at the very least GetMonthName would accept both month
& year as a parameter. See below for why I am leaning toward month & year as
a parameter.

The DateTimeFormatInfo knows how to format DateTime objects, I can see why
there are two types. Two types keep DateTime small, plus it allows date &
time formatting settings to be shared.

DateTime is an immutable structure as its good to have full value semantics
on a Date/Time values, you do not want aliasing on DateTime values.

DateTimeFormatInfo is a not inheritable class, as there is no real behavior
that needs to change, other then what Calendar offers. Being a class allows
you to have a single instance of DateTimeFormatInfo used in many places, in
other words you want aliasing.

GetMonthName is more of a Formatting feature then a "value" feature, hence I
would leave it on DateTimeFormatInfo.

Calendar is a must inherit class, as you have different calendars
(Gregorian, Hebrew, Hindi) that have different behaviors (Leap months,
different leap days).

The one advantage of DateTimeFormatInfo class accepting integers is if any
one defines a true Date type and a true Time type, then DateTimeFormatInfo
can still be used.

The only real short coming I see is that GetMonthName is missing the year
parameter. Or we are missing how it is suppose to work...

A true Date type is a structure that contains only a Date value (no time
part).

A true Time type is a structure that contains only a Time value (no date
part).

AS/400, DB2, Oracle, and other larger data base systems have Time, Date, and
DateTime data types, unlike .NET & SQL Server which currently only have Date
& Time combined into a single type. (I'm not sure if SQL Server 2005 will
offer us Time & Date types, however with .NET CLR integration one should be
able to add Time & Date types).

Hope this helps
Jay

"prosoft" <ifyouneedmyemailpleaseask> wrote in message
news:%Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
Cor Ligthert
Hi Jay,

[Original message clipped]

What did you say yesterday?

I needed only ten minutes more.

:-))))

(Although this was the first time that I did something with that Hebrew
calendar)

Cor

Reply to this message...
 
    
Cor Ligthert
Prosoft,

When I look at Internet it is 26 elul 5764 is that right?

Cor

Reply to this message...
 
    
Cor Ligthert
Prosoft,

With this is the nearest I can reach it, however I become mesjogge from it.

Threading.Thread.CurrentThread.CurrentCulture = _
New System.Globalization.CultureInfo("He-il")
Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat.Calendar = _
New HebrewCalendar
Dim mydate As DateTime = New Date(5763, 13, 26, New HebrewCalendar)
Me.TextBox1.Text = mydate.ToString("MMMM")

I should be near it is only something as a mirror written

Cor

Reply to this message...
 
    
Cor Ligthert
????

And now I paste it is is as you want, .........................

Reply to this message...
 
    
Cor Ligthert
אלול
Reply to this message...
 
    
prosoft
That's correct, see also www.hebcal.com

"Cor Ligthert" <Click here to reveal e-mail address> wrote in message
news:%Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
Cor Ligthert
Prosoft,

I was afraid of that,

My computer tells with the calendertest that it is this year not a leap year
however previous year. See what I made. However I have set the culture using
the threading, maybe that goes with your real settings to he-IL better.

Cor

Reply to this message...
 
 
System.DateTime
System.Diagnostics.Debug
System.Globalization.Calendar
System.Globalization.CultureInfo
System.Globalization.DateTimeFormatInfo
System.Globalization.HebrewCalendar
System.Threading.Thread
System.Windows.Forms.MessageBox




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification