Gregorian date into a Calendar
Many friends in the programming it to Gregorian date code is represented as being automatically Gregorian date into the calendar as well as leap year in which the account being code.
Today the code to convert Gregorian date to the calendar for basic language programmer friends, I have given. This code is quite practical Vtst is
Application of this code is that I long had dealings with it with the IC ds1307 know this is a CD as a real time clock = RTC that also work for other like counting hours, days and ... on the the deaths that calculated using this code can convert on the calendar.
But how should the code of the year, month and day as their deaths the program is described in the following variables set.
Myear = 2008
Mday = 28
Mmonth = 8
On 2008/08/28 the code as we model the output of this code it is produced on a calendar is as follows in this example is on 1387/06/07.
Buy Postal ds1307

In the following code as the output variable Jday day which can become day dates this variable can become the output variable Jmonth months in this code and as output variable Jyear calendar year is also the variable of number of days spent Jdayofyear calculated from the solar month of the first ever show.
'------ Http://www.yazdkit.com------ '
''------ Http://www.yazdkit.ir------- '
$ regfile = "M16def.dat"
$ crystal = 1000000
$ lib "Mcsbyteint.lbx"
Dim Myear As Integer ''input Miladi (gregorian) Year
Dim Mday As Integer 'input Miladi Day
Dim Mmonth As Integer 'input Miladi Month
Dim Mdayofyear As Integer
Dim Myear_ As Integer
Dim Jday As Integer 'output Jalali (shamsi) Day
Dim Jmonth As Integer 'output Jalali Month
Dim Jyear As Integer 'output Jalali Year
Dim Jdayofyear As Integer
Dim Gnumdayofyear As Integer
Dim Isleapyear As Bit
Dim Isleapyearp As Bit
Dim Iloop As Byte
Dim Temp1 As Integer
Dim Temp2 As Integer
Dim Temp3 As Integer
Dim Temp4 As Integer
Dim Jmonth_a (12) As Byte
Dim Mmonth_a (12) As Byte
Mmonth_a (1) = 31
'--- 28 Ya 29 Agar Sall Kabiseh Bashad In Mah 29 Roz Mibashad -------
Mmonth_a (2) = 28
Mmonth_a (3) = 31
Mmonth_a (4) = 30
Mmonth_a (5) = 31
Mmonth_a (6) = 30
Mmonth_a (7) = 31
Mmonth_a (8) = 31
Mmonth_a (9) = 30
Mmonth_a (10) = 31
Mmonth_a (11) = 30
Mmonth_a (12) = 31
Gnumdayofyear = 365
Myear = 2008 'sample Miladi (gregorian) Year
Mday = 28 'sample Miladi Day
Mmonth = 8 'sample Miladi Month
'----- Shart Kabiseh Bodane Sall ---- --
Temp1 = Myear Mod 4
Temp2 = Myear Mod 100
Temp3 = Myear Mod 400
Temp4 = Temp1 And Temp2
If Temp4 <> 0 Or Temp3 = 0 Then
Mmonth_a (2) = 28
Else
Mmonth_a (2) = 29
End If
Myear_ = Myear - 1
Temp1 = Myear_ Mod 4
Temp2 = Myear_ Mod 100
Temp3 = Myear_ Mod 400
Temp4 = Temp1 And Temp2
If Temp4 <> 0 Or Temp3 = 0 Then
Reset Isleapyearp
Else
Set Isleapyearp
End If
Temp1 = Mmonth - 1
For Iloop = 1 To Temp1
Mdayofyear = Mmonth_a (iloop) + Mdayofyear
Next
Mdayofyear = Mday + Mdayofyear
If Mdayofyear> 79 Then
Temp1 = Mdayofyear - 79
Jyear = Myear - 621
If Temp1 <186 Then
Temp2 = Temp1 Mod 31
Temp3 = Temp1 / 31
If Temp2 = 0 Then
Jmonth = Temp3
Jday = 31
Else
Jmonth = Temp3 + 1
Jday = Temp2
End If
Else
Temp2 = Temp1 - 186
Temp3 = Temp2 Mod 30
Temp4 = Temp2 / 30
If Temp3 = 0 Then
Jmonth = Temp4 + 6
Jday = 30
Else
Jmonth = Temp4 + 7
Jday = Temp3
End If
End If
Else
Jyear = Myear - 622
If Isleapyearp = 1 Then
Mdayofyear = Mdayofyear + 11
Else
Mdayofyear = Mdayofyear + 10
End If
Temp2 = Mdayofyear Mod 30
Temp3 = Mdayofyear / 30
If Temp2 = 0 Then
Jmonth = Temp3 + 9
Jday = 30
Else
Jmonth = Temp3 + 10
Jday = Temp2
End If
Waitms 1
End If
Friends who can not provide IP thirty ds1307 can buy the kit must Yazd Shop.
Buy Postal ds1307






Hello and thank a lot
Associate I end my project now and show dates on the moving matrix is in GMT. I Khvbtvn this site a few days of general learned something. Now about the program have a few questions whether this Mthrkh? And one I Whether you come for the appropriate schematic do you because I'm not a schematic that I Sazgarh this program or not. Only I'm in a hurry. Thanks!
Tayebi
Hello
The purpose of your Svaltvn is moving? For example, is left out & after بشه into بشه page? And then The ...
Schematic in your program, simply میشه changes to the program and the schematic to walk or that if I wanted خودمون circuit and to design new maps.
In addition, the tone in the project Vyzgy Forum raised can be answered until comfortable and programs followed. Thanks!
The pic of you in this way can be used.
Info_hatinh.
Hello
I have a problem. When I code I loop I and Mydm the variables day and month and year it ratified the lcd show Mydm start counting days and months immediately Myknn code is used. Please help me
Also, I am using micro atmega 8. I need immediate help. Thanks.
The problem was solved with the variables to zero. But I important.! I converted the code to Calendar deaths need not آخه time I set my project on you and now I use the Keypad and ds1307. After giving dates اونم with the Keypad on the lcd should be Nshvn بشه Hmvntvr Mydvnyd changes that should ds1307 one بشه that should اونم deaths باشه.
Otherwise the code I tried to analyze my code and I write that but I probably Mykhvamv. I Maybe someone can help me I'll Automotive آخه! Pleas help me
I disassemble a convenient way to code the calendar is the ds (Amkansh is) and then while reading a code word on the days and months to Czech.
Hello
The tips but I did not catch the tone ممنون more میشه That explanation.