Just a sample of the Echomail archive
Cooperative anarchy at its finest, still active today. Darkrealms is the Zone 1 Hub.
|    BATPOWER    |    Batch Language Programming    |    216 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 70 of 216    |
|    Paul Quinn to Mark Lewis    |
|    another convoluted brainteaser for the g    |
|    08 Feb 12 15:22:00    |
   
   Hi! mark,   
      
   In a message to Richard Webb you wrote:   
      
    RW>> edit it for leap years, since by default it assumes February has    
    RW>> 28 days.    
      
    ml> you know that you can automatically handle this with a small bit of   
    ml> math, right? i'd have to look at some code to make sure i state it   
    ml> correctly but leap years can be determined by current year div 4 but   
    ml> there's also a 400 involved...   
      
   I think the 400 test is for century years, like: 1900, 2000, 2100 & so on.   
      
    ml> this is why i need to take a sec later   
    ml> on and look at the real formula... then you can have an array with   
    ml> all of the month days count and automatically adjust FEB when it has   
    ml> 29 days ;)   
      
   How about a bit of something in some old Turbo-C...   
      
   --- 8< ---   
   int leap_yr_test(int test_yr)   
   /*   
    function determines if a given year is a leap year   
    Uses: 'test_yr' which is defined prior to function call   
    Pre: none   
    Post: a boolean value is returned indicating TRUE/FALSE   
   */   
   {   
    /* local variables */   
    int result = FALSE;   
      
    switch (test_yr % 100)   
    {   
    case 0 : if ((test_yr % 400) == 0) result = TRUE; break;   
    default : if ((test_yr % 4) == 0) result = TRUE;   
    }   
    /* end switch. */   
    return(result);   
   }   
   /* end function. */   
   --- 8< ---   
      
   =:)   
      
   Cheers,   
   Paul.   
      
   ---    
    * Origin: If it itches, it will be scratched. (3:640/384)   
|
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca