Ignore:
Timestamp:
01/23/04 14:47:01 (21 years ago)
Author:
tbretz
Message:
*** empty log message ***
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mbase/MAstro.cc

    r2604 r2891  
    216216Int_t MAstro::Ymd2Mjd(UShort_t y, Byte_t m, Byte_t d)
    217217{
    218    // Month lengths in days
    219    static int months[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
     218    // Month lengths in days
     219    static int months[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
    220220
    221221    // Validate month
     
    230230        return -1;
    231231
    232     // Lengthen year and month numbers to avoid overflow
     232    // Precalculate some values
    233233    const Byte_t  lm = 12-m;
    234     const ULong_t lm10 = 4712 + y + lm/10;
     234    const ULong_t lm10 = 4712 + y - lm/10;
    235235
    236236    // Perform the conversion
    237     return 1461L*lm10/4 + (306*((21-lm)%12)+5)/10 - (3*((lm10+188)/100))/4 + d - 2399904;
    238 }
     237    return 1461L*lm10/4 + (306*((m+9)%12)+5)/10 - (3*((lm10+188)/100))/4 + d - 2399904;
     238}
Note: See TracChangeset for help on using the changeset viewer.