electro_fuzzy
جمعه 06 بهمن 1391, 11:01 صبح
الگوریتم تقویم شمسی را برای میکرو میخواستم .
Abbas Amiri
جمعه 06 بهمن 1391, 21:54 عصر
سلام  
با چه زبانی ؟
electro_fuzzy
شنبه 07 بهمن 1391, 13:33 عصر
اگه ممکنه با بیسیک باشه . تقویم روز شمار و با در نظر گرفتن سالهای کبیسه. ممنون
Abbas Amiri
شنبه 07 بهمن 1391, 15:17 عصر
سلام 
با یک سرچ ساده نمونه بیسیک آن رامیتونید پیدا کنید . لینک زیر:
http://projects.m32.ir/up/2012/03/RTC_DS1307.rar
این هم یک نمونه برای کد ویژن
// Declare your global variables here
typedef struct {
    int year;
    unsigned char month;
    unsigned char day;
    
    } structDate;
structDate shamsi(structDate M_date);
structDate addDay(int days,structDate M_date);
//************************************************** ************************
void main(void)
{
    structDate shamsiDate, M_date;
    char str[11]; 
lcd_init(20);
    M_date.year =2013;
    M_date.month =1;
    M_date.day=1;
    while (1)
    {  
        lcd_clear(); 
        
        M_date = addDay(1,M_date);  
        lcd_putsf("Miladi: ");
        sprintf(str,"%d/%02d/%02d",M_date.year, M_date.month, M_date.day);               
        lcd_puts(str);
        shamsiDate=shamsi(M_date);
        sprintf(str,"%d/%02d/%02d",shamsiDate.year, shamsiDate.month, shamsiDate.day);    
        lcd_gotoxy(0,1);
        lcd_putsf("Shamsi: "); 
        lcd_puts(str);
        
        delay_ms(250);
    }
}
//************************************************** ***************************
unsigned char miladiLeapYear(int yearMiladi)
{
    if ((!(yearMiladi % 4) && (yearMiladi % 100)) || !(yearMiladi % 400) )
        return 1;
    else
        return 0;
}
//***********************************************
structDate shamsi(structDate M_date)
{
unsigned char miladiMonthDays[12]={31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int  totalMiladiDays, totalShamsiDays, tmpYear;
unsigned char Counter2, Counter1, tmpLeap;
structDate tmpShamsi;
if (!miladiLeapYear(M_date.year))
    miladiMonthDays[1] = 28;
else
    miladiMonthDays[1] = 29; 
    
Counter2 = M_date.month - 1;
totalMiladiDays = 0 ;
for (Counter1 = 0; Counter1<Counter2;Counter1++)
    totalMiladiDays += miladiMonthDays[Counter1];
totalMiladiDays += M_date.day;
if (totalMiladiDays > 79)
{
    tmpShamsi.year  = M_date.year - 621;
    totalShamsiDays = totalMiladiDays - 79;
}
else
{
    tmpShamsi.year  = M_date.year - 622;
    tmpYear = M_date.year - 1 ;
    tmpLeap = miladiLeapYear(tmpYear);
    if (tmpLeap == 0)
        totalShamsiDays = totalMiladiDays + 286;
    else
        totalShamsiDays = totalMiladiDays + 287;
}
tmpShamsi.month  = 1 ;
while (totalShamsiDays > 30)
{
    if (tmpShamsi.month  < 7)
        totalShamsiDays -= 31;
    else
        totalShamsiDays -=  30;
    tmpShamsi.month  ++;
}
if (!totalShamsiDays)
{
    tmpShamsi.month --;
    if (tmpShamsi.month < 7)
        tmpShamsi.day  = 31;
    else
        tmpShamsi.day  = 30;
}
else
    tmpShamsi.day  = totalShamsiDays;  
    
return tmpShamsi;
}
//***********************************************
structDate addDay(int days,structDate M_date)
{
    volatile structDate tmpDate;
    int year;
    char str[11];
    unsigned char month,day;
    unsigned char miladiMonthDays[12]={31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    if (!miladiLeapYear(M_date.year))
        miladiMonthDays[1] = 28;
    else
        miladiMonthDays[1] = 29; 
    
    day = M_date.day; 
    days += day;
    month = M_date.month;
    year = M_date.year;
    while (days > miladiMonthDays[month-1])
    {
        days -= miladiMonthDays[month-1];
        month ++; 
        if (month>12)
        {
            month=1;
            year ++;   
        }   
                                      
    } 
    tmpDate.day = (unsigned char)days;
    tmpDate.month = month;
    tmpDate.year = year; 
    
    return tmpDate;
}
electro_fuzzy
یک شنبه 08 بهمن 1391, 16:26 عصر
منون . اگه ممکنه بگین چطوری محاسبه میکنیم و میفهمیم که مثلا تاریخ 1392/4/10 چند شنبه میشه ؟
1. با در نظر گرفتن سالهای کبیسه
2. تبدیل میلادی به شمسی نمیخوام فقط در مورد شمسی بفرماید که چطوری محاسبه میشه
vBulletin® v4.2.5, Copyright ©2000-1404, Jelsoft Enterprises Ltd.