Hi folks.
        I was recently playing with dates and date types in RPG IV (you
guess why :))), and have found something rather strange.

        Wrote a program to print all leap years from 1 to 9999 using
simple technique: set (*iso, but doesn't metter) date to March 01, and
SUBDUR one day from it. If it ends up with Feb 29, it's a leap year. My
program broke whenever it hit year 300. Same loop, same logic worked for
all years in range from 1 to 9999, but for 300. Further investigation
(dump and source debugger) showed that reason for it was that:

(no format)
D Ddate             s             d     DATFMT(*ISO)
D Ndate             s           8   0
.
.           
C             Z-ADD   3000301     Ndate
C    *ISO     MOVE    Ndate       Ddate

set Ddate to '0300-02-29', and each subsequent use of Ddate crashes the
program, because '0300-02-29' is invalid date (300 is not lep year).

I tried later with string variables and with both numeric and string
literals, but result was the same:

C   *ISO      MOVE   3000301     Ddate  
or
C   *ISO0     MOVE   '03000301'  Ddate

Ddate has value of '0300-02-29'.

Even worse, adding 1 day to '0300-02-28' would result with '0300-02-29'
and than ... crash.

        I've tested it on two V3.7 and one V4.1 system, results are the
same.  Any ideas? What, so significant, had happened in 300 AD? Or
something significant (good party :))) took place that night when IBM-ers
were developing that piece of compiler? Or is it my mistake? 

Can't wait to hear from you,

Vanya


* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* This is the RPG/400 Discussion Mailing List!  To submit a new         *
* message, send your mail to "RPG400-L@midrange.com".  To unsubscribe   *
* from this list send email to MAJORDOMO@midrange.com and specify       *
* 'unsubscribe RPG400-L' in the body of your message.  Questions should *
* be directed to the list owner / operator: david@midrange.com          *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *


As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.