DateConvert library

derez

Expert
Licensed User
Longtime User
The attached library is converting dates from Gregorian or Julian calendars to Hebrew calendar, and vice versa.

It operates on dates from 100 AD.

It operates on desktop and Device.

Requires .NET 2.0

Includes a MoonPhase method, as I found that this functionality of the Hebrew calendar is useful with GPS programs (more than the dates...).

I hope it will be useful to someone. I plan to use it in my Family tree program and in the double calendar program.

Edit: updated to ver 1.1, includes two methods for finding if a year is a Leap year.
Edit: version 1.2 to "immune" against different system regional formats of Date and Time.
Edit: updated to ver 1.3 which can accept dd/mm/yyy or mm/dd/yyyy formats, no matter which regional setting you have.
Edit: ver 1.4 now its done automatically, no need to declare it in New1.
 

Attachments

  • DateConvert1.4.zip
    18.3 KB · Views: 76
Last edited:

derez

Expert
Licensed User
Longtime User
I have a frustrating problem with this library.
When I run an application that use it on my laptop - by the IDE or after compilation, everything works fine.

When I run the same application on my Desktop - it fails whenever it uses the library.

both computers run windows XP. :sign0085:
 
Last edited:

wm.chatman

Well-Known Member
Licensed User
Longtime User
Hello derez

code is still hard to understand, for me. But, I Love your MoonPhase method.

William
 

derez

Expert
Licensed User
Longtime User
Erel
I am trying to change the format of the date but it does not help.

Can you please check if it runs for you ?

William

I think the code is simple. What isn't clear to you ? I'll be glad to explain.
 

derez

Expert
Licensed User
Longtime User
Erel
I changed in my computer the regional settings to Hebrew, so the short date format (which was like yours) changed to dd/mm/yyyy and immediately the program runs like a speedboat.

Now can you help me define the library to become invariant to the format ??

Of course I can change the library to the other format but than it will cause problems to other computers.

Thanks.:BangHead:
 
Last edited:

derez

Expert
Licensed User
Longtime User
:sign0060::sign0060::sign0060:

I added this line:
IFormatProvider culture = new System.Globalization.CultureInfo("fr-FR", true);

and now it does not matter if I use English us (mm/dd/yyyy) or united kingdom (dd/mm/yyyy) or hebrew (dd/mm/yyyy) - it works.

I am updating the library.
 
Last edited:

derez

Expert
Licensed User
Longtime User
I was glad too early, found out this:

If the application is already open in the IDE, the change in the control panel\regional settings does not affect it !

So I still need a way to make the library insensitive to the date format.:sign0085:

In the meantime, if anyone (?) wants to code an application with this library, make the regional settings compatible to dd/mm/yyyy.
 
Last edited:

agraham

Expert
Licensed User
Longtime User
I think you have misunderstood what a CultureInfo does. You have created a "fr-FR" CultureInfo but you never actually use it! You need to specify it when you are parsing something otherwise the System settings are used.

DateTime dt = DateTime.Parse(date, culture)
 

derez

Expert
Licensed User
Longtime User
Thank you Andrew, I already understood it the hard way.

But I managed to work around this problem, starting always with a neutral date (like 1.1.2000) and adding the days, months and years.

I updated the library, with true or false in the New1 it can accept either dd/mm/yyyy or mm/dd/yyyy formats.
 

derez

Expert
Licensed User
Longtime User
I found the way to get the used format and change the library behaviour accordingly.

Updated in ver 1.4, the New1 is now without an argument.
 

wm.chatman

Well-Known Member
Licensed User
Longtime User
Erel
I am trying to change the format of the date but it does not help.

Can you please check if it runs for you ?

William

I think the code is simple. What isn't clear to you ? I'll be glad to explain.
Sorry I just now got to answer you derez. Post #7 help me. Now I understand why your sample did not work.

Take care.

William
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…