波斯日歷與公歷轉(zhuǎn)換算法_第1頁
波斯日歷與公歷轉(zhuǎn)換算法_第2頁
波斯日歷與公歷轉(zhuǎn)換算法_第3頁
波斯日歷與公歷轉(zhuǎn)換算法_第4頁
波斯日歷與公歷轉(zhuǎn)換算法_第5頁
已閱讀5頁,還剩7頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、#if DISPLAY_FARSI_CALENDARtypedef struct MS_U8 weekday;MS_U8 day;MS_U8 month;MS_U16 year; Date_time;static MS_BOOL MApp_IsPersianYearLeap(MS_U32 year)return (year - (year > 0) ? 474 : 473) % 2820) + 474) + 38) * 682) % 2816) < 682;MS_U8 MApp_GetIranDaysOfMonth(MS_U16 u16Year, MS_U8 u8Month)if

2、(u8Month >= 1 && u8Month <= 12) return (MApp_IsPersianYearLeap(u16Year) && u8Month = 12) ? 30 : IranSolarMonthu8Month - 1);else return 0;/ Convert MJD to Jalaliint OutDateLeap(Date_time *des)MS_U8 D, M;MS_U16 Y;MS_U8 r = 0, m = 0;D = des->day;M = des->month;Y = des->ye

3、ar;MS_U8 R;/R = D;/ Jamie shieldedMS_U16 inty;MS_U16 x12 = 0;/ x12 年if (Y > 2059) des->year = 2059;if (M > 12) des->month = 12;if (D > MApp_GetDaysOfThisMonth(des->year, des->month) des->day = MApp_GetDaysOfThisMonth(des->year, des->month);R = des->day;if (M = 1 | M

4、= 2)x12 = 622;else if (M = 3 && R < 20)/ 31kx12 = 622;elsex12 = 621;inty = Y - x12;/ inty 年 1386 年MS_U16 xxx = 1379, i = 0;/ xxx 年BOOL m_ok;do i+;if (inty = xxx) m_ok = TRUE;break;elsem_ok = FALSE;xxx = xxx + 4;/ while (i < 30);/ 30 次if (m_ok = TRUE) if (R < 31 && M = 1)R+;e

5、lse if (R < 28 && M = 2)R+;else if (R < 31 && M = 3)R+;else if (R < 30 && M = 4)R+;else if (R < 31 && M = 5)R+;else if (R < 30 && M = 6)R+;else if (R < 31 && M = 7)R+;else if (R < 31 && M = 8)R+;else if (R < 30 &&

6、; M = 9)R+;else if (R < 31 && M = 10)R+;else if (R < 30 && M = 11)R+;else if (R < 31 && M = 12)R+;else R = 1;M+;/ end if cabiseif (M = 1 && R < 21) r = R + 10;m = 10;else if (M = 1 && R >=21 ) r = R - 20;m = 11;else if (M = 2 && R < 2

7、0) r = R + 11;m = 11;else if (M = 2 && R >= 20) r = R - 19;m = 12;else if (M = 3 && R < 21) r = R + 9;m = 12;else if (M = 3 && R >= 21) r = R - 20;m = 1;else if (M = 4 && R < 21) r = R + 11;m = 1;else if (M = 4 && R >= 21) r = R - 20;m = 2;else

8、if (M = 5 && R < 22) r = R + 10;m = 2;else if (M = 5 && R >= 22) r = R - 21;m = 3;else if (M = 6 && R < 22) r = R + 10;m = 3;else if (M = 6 && R >= 22) r = R - 21;m = 4;else if (M = 7 && R < 23) r = R + 9;m = 4;else if (M = 7 && R >=

9、23) r = R - 22;m = 5;else if (M = 8 && R < 23) r = R + 9;m = 5;else if (M = 8 && R >= 23) r = R - 22;m = 6;else if (M = 9 && R < 23) r = R + 9;m = 6;else if (M = 9 && R >= 23) r = R - 22;m = 7;else if (M = 10 && R < 23) r = R + 8;m = 7;else if (

10、M = 10 && R >= 23) r = R - 22;m = 8;else if (M = 11 && R < 22) r = R + 9;m = 8;else if (M = 11 && R >= 22) r = R - 21;m = 9;else if (M = 12 && R < 22) r = R + 9;m = 9;else if (M = 12 && R >= 22) r = R - 21;m = 10;int x = 0;if (M = 1 | M = 2)x =

11、622;else if (M = 3 && R <= 20)/ 31x = 622;elsex = 621;Y = Y - x;des->day = r;/ return Daydes->month = m;/ return monthdes->year = Y;/ return Yearreturn TRUE;static int OutDateGregorian_k(Date_time *des)/ << input Year Kabiseh >> what => 0 Day 1 Month 2 YearMS_U8 D,

12、 M;MS_U16 Y;/*D = des->day;M = des->month;Y = des->year;MS_U8 m = 0, r = 0;MS_U8 R = 0;R = D;if (M = 1 && R < 13) m = 3;r = R + 19;else if (M = 1 && R >= 13) m = 4;r = R - 12;if (M = 2 && R < 12) m = 4;r = R + 19;else if (M = 2 && R >= 12) m = 5;r

13、 = R - 11;if (M = 3 && R < 12) m = 5;r = R + 20;else if (M = 3 && R >= 12) m = 6;r = R - 11;if (M = 4 && R < 11) m = 6;r = R + 20;else if (M = 4 && R >= 11) m = 7;r = R - 10;if (M = 5 && R < 11) m = 7;r = R + 21;else if (M = 5 && R >=

14、 11) m = 8;r = R - 10;if (M = 6 && R < 11) m = 8;r = R + 21;else if (M = 6 && R >= 11) m = 9;r = R - 10;if (M = 7 && R < 10) m = 9;r = R + 21;else if (M = 7 && R >= 10) m = 10;r = R - 9;if (M = 8 && R < 11) m = 11;r = R + 21;else if (M = 8 &

15、& R >= 11) m = 12;r = R - 10;if (M = 9 && R < 11) m = 11;r = R + 20;else if (M = 9 && R >= 11) m = 12;r = R - 10;/-Y = Y + 621;if (M = 10 && R < 12) m = 12;r = R + 20;/Y+;else if (M = 10 && R >= 12) m = 1;r = R - 11;Y+;if (M = 11 && R < 1

16、3) m = 1;r = R + 19;Y+;else if (M = 11 && R >= 13) m = 2;r = R - 12;Y+;if (M = 12 && R < 11) m = 2;r = R + 18;Y+;else if (M = 12 && R >= 11) m = 3;r = R - 10;Y+;des->day = r;/ return Daydes->month = m;/ return monthdes->year = Y;/ return Yearreturn TRUE;int

17、OutDateGregorian(Date_time *des)/ what => 0Day 1Month 2YearMS_U8 D, M;MS_U16 Y;/*D = des->day; M = des->month; Y = des->year;MS_U8 m = 0, r = 0;MS_U8 R = 0;/*/printf("M = %d D = %d Y = %dn", M, D, Y);if (Y > 2059) des->year = 2059;/ return Yearreturn FALSE;if (M > 12)

18、des->month = 12;/ return monthif (D > MApp_GetIranDaysOfMonth() des->day = 31;/ return Day*/int inty = Y;int xxx = 1379, i = 0;BOOL m_ok;do i+;if (inty = xxx) m_ok=TRUE;break;else m_ok = FALSE;xxx = xxx + 4;/-憂?呷磧?逖 嶅茄 憂?磉惹?- while (i < 30);if (m_ok = TRUE) return OutDateGregorian_k(des)

19、;R = D;if (M = 1 && R < 12) m = 3;r = R + 20;else if (M = 1 && R >= 12) m = 4;r = R - 11;if (M = 2 && R < 11) m = 4;r = R + 20;else if (M = 2 && R >= 11) m = 5;r = R - 10;if (M = 3 && R < 11) m = 5;r = R + 21;else if (M = 3 && R >= 11

20、) m = 6;r = R - 10;if (M = 4 && R < 10) m = 6;r = R + 21;else if (M = 4 && R >= 10) m = 7;r = R - 9;if (M = 5 && R < 10) m = 7;r = R + 22;else if (M = 5 && R >= 10) m = 8;r = R - 9;if (M = 6 && R < 10) m = 8;r = R + 22;else if (M = 6 && R >= 10) m = 9;r = R - 9;if (M = 7 && R < 9) m = 9;r = R + 22;else if (M = 7 && R >= 9) m = 1

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論