Changeset 579 for XIOS/branchs
- Timestamp:
- 03/23/15 11:18:04 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/branchs/xios-1.0/src/duration.cpp
r501 r579 20 20 CDuration & CDuration::operator=(const CDuration & duration) 21 21 { 22 year = duration.year; month = duration.month ;day = duration.day;23 hour = duration.hour; minute = duration.minute; second = duration.second; timestep=duration.timestep 24 return (*this);22 year = duration.year; month = duration.month; day = duration.day; 23 hour = duration.hour; minute = duration.minute; second = duration.second; timestep=duration.timestep; 24 return *this; 25 25 } 26 26 … … 29 29 StdOStringStream sout; 30 30 bool testValue = true; 31 if(duration.year != 0.0) { testValue = false; sout << duration.year << "y " 31 if(duration.year != 0.0) { testValue = false; sout << duration.year << "y "; } 32 32 if(duration.month != 0.0) { testValue = false; sout << duration.month << "mo "; } 33 if(duration.day != 0.0) { testValue = false; sout << duration.day << "d " 34 if(duration.hour != 0.0) { testValue = false; sout << duration.hour << "h " 33 if(duration.day != 0.0) { testValue = false; sout << duration.day << "d "; } 34 if(duration.hour != 0.0) { testValue = false; sout << duration.hour << "h "; } 35 35 if(duration.minute != 0.0) { testValue = false; sout << duration.minute << "mi "; } 36 if(duration.second != 0.0) { testValue = false; sout << duration.second << "s " 37 if(duration.timestep != 0.0 || testValue) { sout << duration.timestep << "ts " 36 if(duration.second != 0.0) { testValue = false; sout << duration.second << "s "; } 37 if(duration.timestep != 0.0 || testValue) { sout << duration.timestep << "ts "; } 38 38 39 39 // << suppression de l'espace en fin de chaîne. 40 40 out << (sout.str().substr(0, sout.str().size()-1)); 41 return (out);41 return out; 42 42 } 43 43 … … 50 50 while (!in.eof()) 51 51 { 52 if (!(in >> v >> c)) 52 if (!(in >> v >> c)) 53 53 { 54 //DEBUG("----> Pb StdIStream & operator>>(StdIStream & in , CDuration & duration)") 55 //if (in.eof()) DEBUG("----> Fin de fichier StdIStream & operator>>(StdIStream & in , CDuration & duration)") 54 //DEBUG("----> Pb StdIStream & operator>>(StdIStream & in , CDuration & duration)"); 55 //if (in.eof()) DEBUG("----> Fin de fichier StdIStream & operator>>(StdIStream & in , CDuration & duration)"); 56 56 } 57 if (in.eof()) 57 if (in.eof()) 58 58 { 59 //DEBUG("----> Fin de fichier StdIStream & operator>>(StdIStream & in , CDuration & duration)") 60 break 59 //DEBUG("----> Fin de fichier StdIStream & operator>>(StdIStream & in , CDuration & duration)"); 60 break; 61 61 } 62 62 switch (c) … … 82 82 { 83 83 in >> c; 84 if (c=='s') duration.timestep = v; 84 if (c=='s') duration.timestep = v; 85 85 break; 86 86 } 87 87 88 88 default: 89 89 StdString valc; valc.append(1, c); … … 92 92 } 93 93 } 94 return (in);94 return in; 95 95 } 96 96 … … 101 101 if ((year == 0) && (month == 0) && (day == 0) && 102 102 (hour == 0) && (minute == 0) && (second == 0) && (timestep == 0)) 103 return (true);104 return (false);103 return true; 104 return false; 105 105 } 106 106 … … 108 108 CDuration & CDuration::solveTimeStep(const CCalendar & c) 109 109 { 110 CDuration timeStep=c.getTimeStep() ; 111 second +=timestep*timeStep.second ; 112 minute +=timestep*timeStep.minute ; 113 hour +=timestep*timeStep.hour ; 114 day +=timestep*timeStep.day ; 115 month +=timestep*timeStep.month ; 116 year +=timestep*timeStep.year ; 117 timestep = 0 ; 110 CDuration timeStep=c.getTimeStep(); 111 second +=timestep*timeStep.second; 112 minute +=timestep*timeStep.minute; 113 hour +=timestep*timeStep.hour; 114 day +=timestep*timeStep.day; 115 month +=timestep*timeStep.month; 116 year +=timestep*timeStep.year; 117 timestep = 0; 118 return *this; 119 } 118 120 119 }120 121 122 121 CDuration & CDuration::resolve(const CCalendar & c) 123 122 { … … 139 138 month += modf(year, &year) * (float)c.getYearLength(); 140 139 year += int(month) /c.getYearLength(); month = int(month)%c.getYearLength(); 141 return (*this);140 return *this; 142 141 } 143 142 … … 148 147 const CDuration & own = *this; 149 148 StdOStringStream oss; oss << own; 150 return (oss.str());149 return oss.str(); 151 150 } 152 151 … … 155 154 CDuration dr = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; 156 155 StdIStringStream iss(str); iss >> dr; 157 return (dr);156 return dr; 158 157 } 159 158 160 159 ///--------------------------------------------------------------- 161 162 163 160 } // namespace xios 164 161
Note: See TracChangeset
for help on using the changeset viewer.