sponsored links

Collapse

Announcement

Collapse
No announcement yet.

back to the year 300

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • back to the year 300

    when having this piece of code
    (yes it is initially the year 219 instead of 2019)

    w_date = d'01.11.0219';
    dow w_date < d'31.12.2019';
    w_date = w_date + %days(1);
    enddo;

    the 'program' crashes on date '28.02.0300'
    does someone has an idea why ?

  • #2
    I suspect it's actually crashing on '29.02.0300' which is apparently not a valid leap date. I've never dealt with dates this old. Is this just an exercise?

    Ringer

    Comment


    • #3
      I can't recall the exact years, but date math in RPG is only valid within a specific range of years, It covers a long period - but not that long. I _think_ the earliest date may be the start of the gregorian calendar but not sure.

      Why on earth would you want those dates to work anyway?

      Comment


      • #4
        Is this just an exercise or are you really needing to calculate dates way back then? If you are needing to calculate dates back that far, then you're in for a very difficult time! There are a plethora of calendars from various countries, not to mention the different dates of adoption of various calendars etc etc. As such, you would need to construct your own routines to take into account the plethora of variables and inconsistencies in the calendars...

        RPG has a valid date range and my guess is the system might calculate back to Oct 1582 as during that month was the "official" cutover to the Gregorian calendar. That's just a guess though so don't take it as gospel lol. The problem though is that not all countries adopted it straight away, taking about 300 years for it to finally become a standard. That means that 1927 technically is the first year that reliable calculations can be made using the Gregorian calendar as that was when the last country (Turkey) moved to the Gregorian Calendar. As such date arithmetic is complicated even for quite recent years. For example, what date do you get if you add 1 day to 18.12.1926? It would be 19.12.1926 here but in Turkey it would be 01.01.1927.

        Comment


        • #5
          Try converting it to Julian first.
          Regards

          Kit
          http://www.ecofitonline.com
          DeskfIT - ChangefIT - XrefIT
          ___________________________________
          There are only 3 kinds of people -
          Those that can count and those that can't.

          Comment


          • #6
            it was something we encountered today (yesterday)

            a user had entered a date (regarding to closing days / holidays) in the year 219 (31.05.0219) instead of 2019 (31.05.2019)
            the only check on input nowadays is that the date should be valid (31.05.0219 is a valid date)

            in another program there is an algorithm that makes some checks with those dates
            it starts with that initial date (31.05.0219), makes a certain check and if that check fails it adds 1 day and we make the check again

            beside the fact of the code is well-written or not ... i was wondering why it crashes on that date calculation ?

            meanwhile our code has changed so the problem can't appear anymore
            i did the check and that error doesn't occur on other dates (since 01.01.0001)

            thanks for your answers and explanations

            Comment

            sponsored links

            Collapse

            Working...
            X