473,756 Members | 8,443 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

convert gregorian date to jalay date

how i can convert gregorian date to jalaly(Iran date)
with vb.net
Nov 17 '05 #1
1 2204
"h_ghanaty" <h_*******@yaho o.com> wrote in message
news:0a******** *************** *****@phx.gbl.. .
how i can convert gregorian date to jalaly(Iran date)
with vb.net


I don't know VB.NET but I came up with this C# code which you can probably
translate pretty easily. It uses the 8-of-33 leap year method which only
works within a certain range of years because of how the Jalali leap years
are calculated.

const long ticksPerDay = 864000000000L;

static int[] leapFlag =
{0,1,0,0,0,1,0, 0,0,1,0,0,0,1,0 ,0,0,1,0,0,0,0, 1,0,0,0,1,0,0,0 ,1,0,0};

public static void GetJalaliDate(D ateTime time, out int year, out int month,
out int day)
{
const int daysIn33Years = 365 * 33 + 8;
int d = (int) (time.Ticks / ticksPerDay) - 226529;
year = (d / daysIn33Years) * 33;
d %= daysIn33Years;
for (int i=0; i<33; i++)
{
int daysInYear = 365 + leapFlag[i];
if (d < daysInYear)
break;
d -= daysInYear;
year++;
}
if (d < 186)
{
month = 1 + d / 31;
day = 1 + d % 31;
}
else
{
d -= 186;
month = 7 + d / 30;
day = 1 + d % 30;
}
}

Nov 17 '05 #2

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

Similar topics

4
5390
by: Richard Hollenbeck | last post by:
I'm trying to write some code that will convert any of the most popular standard date formats twice in to something like "dd Mmm yyyy" (i.e. 08 Jan 1908) and compare the first with the second and calculate days, months, and years. This is not for a college course. It's for my own personal genealogy website. I'm stumped about the code. I'm working on it but not making much progress. Is there any free code available anywhere? I know it...
5
16333
by: goochey | last post by:
I'm trying to convert a Julian Date (Format "4365") into an actual calendar date in Visual Basic, can anyone help me out with this.
5
16090
by: SalimShahzad | last post by:
Dear Respected Gurus, I need a coding assistant converting from gregorian to hijri and vice versa. I have problem with this codes. the problem Gregorian to Hijri gives 100% results. when i enter this to Hijri to gregorian it either do nothing or go to next record on form. well there r two fields on form that r calc afterevents each other dates. ur assistance will be highly appreciated, if any one can tell what is wrong with this codes
1
4899
by: Raja | last post by:
Hi Anyone has any idea of how to convert Julian Date (eg. 12744057862..) to a VB.NET date time. Thanks in advance.
1
4545
by: Sam | last post by:
How do I convert Julian Date to Calendar Date in ASP.Net 1.1 based on following guideline found at Internet? To convert Julian date to Gregorian date: double JD = 2299160.5; double Z = Math.Floor(JD+0.5); double W = Math.Floor((Z - 1867216.25)/36524.25); double X = Math.Floor(W/4);
15
9074
by: JenHu | last post by:
Hi expert, I have a data field (birthdate) contains a datetime datatype (mm/dd/yyyy), how can I convert to mmdd?? say, the birthday is 8/1/1979 and convert to mmdd DOB = DS.Tables("AcctInfoTble").Rows(3)("BRTHDATE") strResult.Insert(12, DOB.PadLeft(37, " ")) ---------------------------------------------------------------------------------------------------
4
7390
by: Holmsey | last post by:
Hi I have to convert am today's date and time (now) to a webservice. The example the web service gives was "1163313527144#" which comes out to 12/31/1969 06:00 PM. How do I convert a date to a 13 digit long value?
3
17504
by: Lonifasiko | last post by:
Hi, I want to convert an UTC time to a Date object in Javascript. The UTC time we have is a string that looks like "1160720058.377452373" for example. I've done it in Java but I'm not able to do it via Javascript, that should be pretty similar...
3
2561
by: nisse2562 | last post by:
this code: http://pastebin.com/f168570c8 gives the compile error: test_templates.cpp: In function 'int main(int, char**)': test_templates.cpp:51: error: expected `(' before 'g' test_templates.cpp:51: error: expected `)' before ';' token test_templates.cpp:51: error: invalid const_cast from type 'bar<lab2::Gregorian>' to type 'bar<lab2::Julian>*' where the Julian and Gregorian are date classes that inherit from Date How do I "make" the...
0
9287
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10046
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9886
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9857
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8723
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7259
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6542
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3369
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2677
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.