Changeset 1760 for trunk/MagicSoft/Cosy/base/timer.cc
- Timestamp:
- 02/16/03 17:02:06 (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Cosy/base/timer.cc
r1759 r1760 13 13 fMs = tv_usec; 14 14 15 SetMjd((fMs+fSecs)/(60*60*24) + 40587); 16 15 17 fSec = tv_sec%60; 16 18 tv_sec /= 60; … … 22 24 tv_sec /= 24; 23 25 24 Set(tv_sec + 40587); 25 26 fDiv = fmod((fMs+fSecs)/(60*60*24), 1.0); 26 // fDiv = fmod((fMs+fSecs)/(60*60*24), 1.0); 27 27 } 28 28 /* 29 29 void Timer::Set(const long mjd) 30 30 { 31 SetMjd(mjd); 32 31 33 // 32 34 // Express day in Gregorian calendar 33 35 // (taken from slalib slaDjcl) 34 36 // 35 fMjd = mjd;36 37 37 const long jd = mjd + 2400001; 38 38 const long n4 = (((((jd*4-17918)/146097)*6)/4+1)/2+jd-37)*4; … … 43 43 fDay = (nd10%306)/10 + 1; 44 44 } 45 45 */ 46 46 void Timer::SetTimer(const struct timeval *tv) 47 47 { … … 77 77 void Timer::SetMjd(double mjd) 78 78 { 79 Set((long)mjd); 79 // 80 // Express day in Gregorian calendar 81 // (taken from slalib slaDjcl) 82 // 83 fMjd = mjd; 84 85 const long jd = (long)mjd + 2400001; 86 const long n4 = (((((jd*4-17918)/146097)*6)/4+1)/2+jd-37)*4; 87 const long nd10 = (((n4-237)%1461)/4)*10+5; 88 89 fYea = n4/1461 - 4712; 90 fMon = ((nd10/306+2)%12) + 1; 91 fDay = (nd10%306)/10 + 1; 80 92 81 93 fDiv = fmod(mjd, 1.0); … … 84 96 85 97 mjd *= 24; 86 fHor = (int) mjd;98 fHor = (int)fmod(mjd, 24); 87 99 88 100 mjd *= 60; 89 fMin = (int) mjd;101 fMin = (int)fmod(mjd, 60); 90 102 91 103 mjd *= 60; 92 fSec = (int) mjd;104 fSec = (int)fmod(mjd, 60); 93 105 94 fMs = mjd * 1000;106 fMs = fmod(mjd * 1000, 1000); 95 107 } 96 108
Note:
See TracChangeset
for help on using the changeset viewer.