Ignore:
Timestamp:
Nov 2, 2005, 9:52:39 AM (20 years ago)
Author:
ansari
Message:

1/ Correction bug TimeStamp::ToDays() + petites amelioration
2/ Prise en compte du type TimeStamp dans MuTyV (sous forme de r_8 en interne)
3/ Adaptation DVList a modifs MuTyV (typ TimeStamp) et R/W PPersist

+ Petites corrections et MAJ num.version , Reza 2 Nov 2005

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaLib/BaseTools/timestamp.cc

    r2805 r2826  
    6969}
    7070
     71TimeStamp::TimeStamp(int_8 days, r_8 seconds)
     72{
     73  Set(days, seconds);
     74}
     75
    7176TimeStamp::TimeStamp(string& date, string& hour)
    7277{
     
    9095void TimeStamp::Set(double days)
    9196{
    92   if (days < 0.) {
    93     mDays = days;
    94     mSeconds = (days-mDays)*86400.;
     97  if (days >= 0.) {
     98    mDays = trunc(days);
     99    mSeconds = (days-trunc(days))*86400.;
    95100  }
    96101  else {
    97     mDays = trunc(days)-1;
    98     mSeconds = (days-mDays)*86400.;
    99   }
     102    if ( (trunc(days)-days) > 0.) {
     103      mDays = trunc(days)-1;
     104      mSeconds = (days-mDays)*86400.;
     105    }
     106    else {
     107      mDays = trunc(days);
     108      mSeconds = 0.;
     109    }
     110  }
     111}
     112
     113void TimeStamp::Set(int_8 days, r_8 seconds)
     114{
     115  if ( (seconds < 0.) || (seconds > 86400.) )
     116    throw ParmError("TimeStamp::Set(int_8, r_8) seconds<0 or seconds>86400.");
     117  mDays = days;
    100118}
    101119
     
    178196  seconds -= hour*3600;
    179197  min = trunc(seconds/60.);
     198  while (min >= 60) { hour++; min -= 60; }
    180199  sec = seconds-min*60;
    181 }
     200  while (sec >= 60.) { min++; sec -= 60.; }
     201}
     202
    182203double TimeStamp::ToDays() const
    183204{
     
    185206}
    186207
    187 string TimeStamp::ToString() const
     208/*!
     209\param fgday : if false, ignore the date (dd/mm/yy) part
     210\param fghour : if false, ignore the hour (hh:mm:ss) part
     211*/
     212string TimeStamp::ToString(bool fgday, bool fghour) const
    188213{
    189214  char buff[128];
     
    193218  GetDate(aa, mm, jj);
    194219  GetHour(hh, min, sec);
    195   sprintf(buff,"%02d/%02d/%02d %02d:%02d:%02.1f GMT", jj,mm,aa,hh,min,sec);
     220  if (!fghour)
     221    sprintf(buff,"%02d/%02d/%02d ", jj,mm,aa);
     222  else if (!fgday)
     223    sprintf(buff,"%02d:%02d:%02.3f ", hh,min,sec);
     224  else
     225    sprintf(buff,"%02d/%02d/%02d %02d:%02d:%02.1f GMT", jj,mm,aa,hh,min,sec);
    196226  return buff;
    197227}
    198228
    199 void TimeStamp::Print(ostream& os)  const
    200 {
    201   os << " " << ToString() << " ";
     229/*!
     230\param fgday : if false, ignore the date (dd/mm/yy) part
     231\param fghour : if false, ignore the hour (hh:mm:ss) part
     232*/
     233void TimeStamp::Print(ostream& os, bool fgday, bool fghour)  const
     234{
     235  os << " " << ToString(fgday, fghour) << " ";
    202236}
    203237
Note: See TracChangeset for help on using the changeset viewer.