Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.clipper.visual-objects > #6080
| From | "Jamal" <jamal@examples.net> |
|---|---|
| Newsgroups | comp.lang.clipper.visual-objects |
| Subject | Gregorian Date to Hijri Date |
| Date | 2013-10-11 17:32 -0400 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <l39qoc$5j3$1@speranza.aioe.org> (permalink) |
Hi All and Rob Smith,
Here is a function that will convert a Gregorian date to Islamic Hijri Date.
It seems to work based on my testing.
Since Islamic dates are based on Lunar months, the conversion could be off
by a day. An offset (adjustment) has to be considered in getting Hijri date;
code below does not handle this.
Usage:
Date2Hijri(CToD("10/11/2020"), 0)
Date2Hijri(Today(), 0)
Date2Hijri(Today(), 1)
FUNCTION Date2Hijri(dDate AS DATE, dwFormat AS LONGINT) AS STRING PASCAL
// Original code found at
https://groups.google.com/forum/#!topic/microsoft.public.navision/z6_8cLg-He4
by Ian C.
// Updated and Optimized (less code) to work in VO 2.8 by Jamal Assaf (Oct
11, 2013)
// dwFormat: 0 returns d/m/year 6/12/1434
// 1 returns day of week, day, islamic month, year
// For example: Date2Hijri(ctod("10/11/2013"), 0), returns 6/12/1434
// For example: Date2Hijri(ctod("10/11/2013"), 1), Friday 6 Dhu'l-Hijja
1434 A.H.
LOCAL d := Integer(Day(dDate)) AS LONGINT
LOCAL m := Integer(Month(dDate)) AS LONGINT
LOCAL y := Integer(Year(dDate)) AS LONGINT
LOCAL l,n,j AS LONGINT
LOCAL dwNewDate AS LONGINT
LOCAL cHiriDate AS STRING
IF (y > 1582) .OR. (y = 1582) .AND. (m > 10) .OR. (y = 1582) .AND. (m
= 10) .AND. (d > 14)
dwNewDate := integer((1461 * (y + 4800 + integer((m-14) / 12 ))) /
4) + integer((367 * (m-2-12 * (integer((m-14) / 12 )))) / 12) - ;
Integer((3 * (Integer( (y + 4900 + Integer((m-14) / 12)) /
100 ))) / 4) + d - 32075
ELSE
dwNewDate := 367 * y - Integer((7 * (y + 5001 + Integer((m-9) / 7)))
/ 4) + Integer((275 * m) / 9) + d + 1729777
ENDIF
l := Integer(dwNewDate - 1948440 + 10632)
n := Integer((l - 1) / 10631)
l := l - 10631 * n + 354
j := (Integer((10985 - l) / 5316)) * (Integer((50 * l) / 17719)) +
(Integer(l / 5670)) * (Integer((43 * l) / 15238))
l := l - (Integer((30 - j) / 15)) * (Integer((17719 * j) /50)) -
(Integer(j / 16)) * (Integer((15238 * j) / 43)) + 29
m := Integer((24 * l) / 709)
d := l - Integer((709 * m) / 24)
y := 30 * n + j - 30
IF dwFormat = 0
cHiriDate := NTrim(d)+"/"+NTrim(m) + "/" + NTrim(y)
ELSEIF dwFormat = 1
cHiriDate := CDoW(dwNewDate) + " " + NTrim(d) + " " +
GetLunarMonth(m) + " " + NTrim(y) + " A.H."
ENDIF
RETURN cHiriDate
Jamal
Back to comp.lang.clipper.visual-objects | Previous | Next — Next in thread | Find similar | Unroll thread
Gregorian Date to Hijri Date "Jamal" <jamal@examples.net> - 2013-10-11 17:32 -0400
Re: Gregorian Date to Hijri Date Sherlock <sherlock@sherlock.com.au> - 2013-10-11 19:20 -0700
Re: Gregorian Date to Hijri Date "Jamal" <jamal@examples.net> - 2013-10-12 00:22 -0400
Re: Gregorian Date to Hijri Date Rob Smith <rasmithhalifax@gmail.com> - 2013-10-14 04:26 -0700
csiph-web