Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
I need explanation?!?
Message
From
11/04/2009 17:03:07
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01394364
Message ID:
01394368
Views:
92
>Why this code bombs on first and 3d line but not on second?
>
>? DATE(1430,4,15) && BOOM!!!
>? ConvertHijriDateToGregorianDate(DATE(1430,4,15)) && Fine
>? ConvertGregorianDateToHijriDate(DATE(2009,4,11)) && BOOM!!!
>
>Function ConvertHijriDateToGregorianDate(ldHijriDate)
>    d = DAY(ldHijriDate)
>    m = MONTH(ldHijriDate)
>    y = YEAR(ldHijriDate)
>    jd = INT((11 * m.y + 3) / 30) + 354 * m.y + 30 * m.m - INT((m.m- 1 )/ 2) + m.d + 1948440 - 385
>    IF (m.jd > 2299160 )
>       l = m.jd + 68569
>       n = INT((4 * m.l) / 146097)
>       l = m.l - INT((146097 * m.n + 3) / 4)
>       i = INT((4000*(m.l+1)) / 1461001)
>       l = m.l - INT((1461*m.i)/4)+31
>       j = INT((80*m.l)/2447)
>       d = l-INT((2447*m.j)/80)
>       l = INT(m.j/11)
>       m = m.j+2-12*l
>       y = 100*(m.n-49)+m.i+m.l
>    ELSE
>       j = m.jd + 1402
>       k = INT(m.j-1)/1461)
>       l = m.j-1461*m.k
>       n = INT((m.l-1)/365)-INT(m.l/1461)
>       i = m.l-365*n+30
>       j = INT((80*m.i)/2447)
>       d = i-INT((2447*m.j)/80)
>       i = INT(m.j/11)
>       m = m.j+2-12*m.i
>       y = 4*m.k+m.n+m.i-4716
>    ENDIF
>   
>RETURN DATE(m.y, m.m, m.d)
>
>Function ConvertGregorianDateToHijriDate(ldGregorianDate)
>    d = DAY(ldGregorianDate)
>    m = MONTH(ldGregorianDate)
>    y = YEAR(ldGregorianDate)
>    IF ldGregorianDate > DATE(1582,10,14)
>       jd = INT((1461*(m.y+4800+INT((m.m-14)/12)))/4)+;
>            INT((367*(m.m-2-12*(INT((m.m-14)/12))))/12)-;
>            INT( (3* (INT(  (m.y+4900+INT((m.m-14)/12))/100)))/4)+m.d-32075
>    ELSE
>       jd = 367*m.y-INT((7*(m.y+5001+INT((m.m-9)/7)))/4)+INT((275*m.m)/9)+m.d+1729777
>    ENDIF
>    l = m.jd - 1948440 + 10632
>    n = INT((m.l-1)/10631)
>    l = m.l-10631*m.n+354
>    j = (INT((10985-m.l)/5316))*(INT((50*m.l)/17719))+(INT(m.l/5670))*(INT((43*m.l)/15238))
>    l = m.l - (INT((30-m.j)/15))*(INT((17719*m.j)/50))-(INT(j/16))*(INT((15238*m.j)/43))+29
>    m = INT((24*m.l)/709)
>    d = m.l - INT((709*m.m)/24)
>    y = 30 * m.n + m.j - 30
>    ? m.y, m.m, m.d
>RETURN DATE(m.y, m.m, m.d)
>
>
>I try to convert a JAVA script from here:http://www.mela.us/committees/hegira.html to VFP The first function works (at least it not bombs) but the second gives me "Date/Datetime evaluated to invalid value".
>How's that?
>If 15 Apr. (or whatever name it is) 1430 is invalid why VFP not bombs when I sent it as parameter?

I only tried the first line of your code, but it does not crash or error in VFP9 SP1.

It works with all 3 settings of STRICTDATE. What is your SET DATE?
Regards. Al

"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov

Neither a despot, nor a doormat, be

Every app wants to be a database app when it grows up
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform