int tt=0;
int sYear=0;
int sD=0;
int sMonth=0;
int sDay=0;
int dWM[12]={0, 31,59,90,120,151,181,212,243,273,304,334};
int dWKM[12]={0,31,60,91,121,152,182,213,244,274,305,335};
int IM[12]={31,31,31,31,31,31,30,30,30,30,30,29};
int IKM[12]={31,31,31,31,31,31,30,30,30,30,30,30};
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
Miladitoshamsi(2015, 2, 28);
Miladitoshamsi(2016, 2, 28);
Miladitoshamsi(2017, 2, 28);
Miladitoshamsi(2015, 3, 20);
Miladitoshamsi(2016, 3, 19);
Miladitoshamsi(2017, 3, 20);
Miladitoshamsi(2015, 3, 21);
Miladitoshamsi(2016, 3, 20);
Miladitoshamsi(2017, 3, 21);
Miladitoshamsi(2015, 9, 22);
Miladitoshamsi(2016, 9, 21);
Miladitoshamsi(2017, 9, 22);
Miladitoshamsi(2015, 9, 23);
Miladitoshamsi(2016, 9, 22);
Miladitoshamsi(2017, 9, 23);
Miladitoshamsi(2015, 12, 23);
Miladitoshamsi(2016, 12, 22);
Miladitoshamsi(2017, 12, 23);
delay (50000);
}
void Miladitoshamsi(int iYear, int iMonth, int iDay) {
Serial.println("iyear= ");
Serial.println(iYear);
Serial.println("iMonth= ");
Serial.println( iMonth);
Serial.println("iDay= ");
Serial.println(iDay);
if(iYear==((iYear/4)*4) ){
if((iMonth>2&iDay>19)|| iMonth>3){
sYear=iYear-621;
tt=dWKM[iMonth-1]+iDay-80;
}
else
{
sYear=iYear-622;
tt=dWKM[iMonth-1]+iDay+285;
}
}
else
{
// tt=(iYear/4)+(iYear*365)+(dWM[(iMonth-1)]+iDay);
if((iMonth>2&iDay>20)|| iMonth>3){
sYear=iYear-621;
tt=dWM[iMonth-1]+iDay-80;
}
else
{
sYear=iYear-622;
tt=dWM[iMonth-1]+iDay+285;
}
}
Serial.println("tt=");
Serial.println(tt);
sD=tt;
if( sD> 185){
sMonth=7+((sD-186)/30);
sDay=sD-(185+(((sD-186)/30)*30));
if((iYear-1)==(((iYear-1)/4)*4) & iMonth<4){
sD=sD;
sMonth=7+((sD-186)/30);
sDay=1+sD-(185+(((sD-186)/30)*30));
}
}
if( sD< 186){
sMonth=((sD)/31)+1;
sDay=(1+sD-((sMonth-1)*31));
}
String stringOne=String(sYear)+"/"+String(sMonth)+"/"+String(sDay);
Serial.println("Shamsi= ");
Serial.print(stringOne);
Serial.println(" ");
delay (500);
}