• Subject: Re: Can I get the Day of the week?
  • From: boldt@xxxxxxxxxx
  • Date: Wed, 16 May 2001 08:11:47 -0400
  • Importance: Normal

From: "Christopher J. Devous" <cdevous@antigua.com>
Subject: RE: Can I get the Day of the week?
Christopher wrote:
>Try this, it's based on the famous "Doomsday" algorithm by JH Conway:
>
>    100
**************************************************************************
>    200       ***
>    300       ***      Program Name --  DOWK
>    400       ***      Description  --  Calculate Day of Week from
Gregorian
>    500       ***                       Date
>    600       ***      Author       --  Christopher J. Devous

As much as I respect John Horton Conway, RPG programmers can't do
day of week computation much shorter than with this procedure:

 //\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\//
 // Procedure:  DayOfWeek                                           //
 // Purpose:  Determine the day of week for a particular date       //
 // Parameters:                                                     //
 //    I: dt   -- date                                              //
 // Returns:                                                        //
 //    0..6    -- 0=Sunday, 1=Monday, 2=Tuesday, etc.               //
 // Notes:                                                          //
 //    January 5, 1800 is a Sunday.  This procedure only works for  //
 //    dates later than 1800-01-05.                                 //
 //\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\//
P DayOfWeek       b
D DayOfWeek       pi            10i 0
D   dt                            d   value datfmt(*iso)
 /free
    return %rem (%diff (dt: d'1800-01-05': *days): 7);
 /end-free
P DayOfWeek       e





Hans Boldt, ILE RPG Development, IBM Toronto Lab, boldt@ca.ibm.com

+---
| This is the RPG/400 Mailing List!
| To submit a new message, send your mail to RPG400-L@midrange.com.
| To subscribe to this list send email to RPG400-L-SUB@midrange.com.
| To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.com
+---

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

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

This mailing list archive is Copyright 1997-2022 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.