Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

Arabic date

 [1/1] from: rebol-list2::seznam::cz at: 15-Nov-2002 12:13


Hello rebol-list, I've just found this script on one of my archive CDs and because I've never publicated it and because now, when one texas cowboy is planning to get other fields for his cattle, maybe this small script will be useful to him.... cheers Oldes PS: I've never had a possibility to check if it's correct calculation, so if someone know the official arabic date, please compare it. PPS: and if someone know where to find arabic month names written in arabic I would appreciate it as well (for a view version:-) =( Oliva David )=======================( [oliva--david--seznam--cz] )== =( Earth/Europe/Czech_Republic/Brno )============================= =( coords: [lat: 49.22 long: 16.67] )============================= -- Attached file included as plaintext by Listar -- -- File: islam-cal.r rebol [ title: "Islam calendar (arabic version)" author: 'oldes file: %islam-cal.r email: [oliva--david--seznam--cz] date: 5-12-2001 version: 0.0.2 purpose: {To learn how works this type of calendar} comment: {I would like to dedicate this script to our brave American soldiers which are (will be / were) fighting for the planetary prosperity, stability, freedom and oil fields in Arabia.} ] rounded: func["Returns true integer ([-1.5] = -2)" i][ either i < 0 [to-integer (i - 0.5)][to-integer i + 0.5] ] idiv: func[a b][rounded divide a b] sM: func[m y][ x: pick [0 31 59 90 120 151 181 212 243 273 304 334] m if (y // 4) = 0 [ either m = 1 [x: -1][if m = 2 [x: 30]] ] x ] get-jd: func[date /local JD D M Y][ set [D M Y] reduce [date/day date/month date/year] return JD: D + (sM M Y) + (365 * Y) + (idiv Y 4) - (idiv Y 100) + (idiv Y 400) + 1721060 ] arabic-to-jd: func[D M H /local h1 h2][ h1: rounded (H - 1) / 30 h2: remainder (H - 1) 30 return JD: D + (29 * (M - 1)) + (rounded (m / 2)) + (10631 * h1) + (354 * h2) + (rounded ((11 * h2 + 14) / 30)) + 1948439 ] ;print arabic-to-jd 1 1 1 arabic-months: [ "'Al-muharram" "Safar" "Rabi` al-'awwal" "Rabi` at-tani" "Džumada 'l-'ula" "Džumada 'l-'achira" "Radžab" "Ša`ban" "Ramadan" "Šawwal" "Du 'l-qa`da" "Du 'l-hidždža" ] jd-to-arabic: func[ "Converts JulianDate to Islamic date in arabic cycle" jd "Julian date" /text "Returns the date as a text" /local x h1 h2 q1 q2 H M D ][ x: JD - 1948440 h1: rounded (x / 10631) q1: remainder x 10631 h2: 0 while [((354 * h2) + rounded ((11 * h2 + 14) / 30)) <= q1][h2: h2 + 1] h2: h2 - 1 q2: q1 - ((354 * h2) + rounded ((11 * h2 + 14) / 30)) H: 30 * h1 + h2 + 1 M: 1 D: 1 short-month?: false while [(abs q2) <> ((D - 1) + (29 * (M - 1)) + rounded (M / 2))][ D: D + 1 if any [ all [short-month? D = 30] all [not short-month? D = 31] ][ D: 1 M: M + 1 short-month?: not short-month? ] if M > 12 [return none] ;wrong date ] rejoin either text [ [D "." arabic-months/:M " " H] ][ [D "-" M "-" H] ] ] date-to-arabic: func[date][jd-to-arabic/text get-jd date] ;just a fullcircle test: ;print jd-to-arabic arabic-to-jd 1 1 1 print rejoin ["Today is: " date-to-arabic now]