Changeset 05d3c2d in tol


Ignore:
Timestamp:
Aug 12, 2013, 2:46:25 PM (13 years ago)
Author:
Pedro Gea <pgea@…>
Branches:
1941-docker-image-to-test, devel, master
Children:
88d8fd9
Parents:
d4ea7bd
Message:

Refs #1720
Se redondean los segundos hasta las centésimas mediante la macro SECONDROUND, de acuerdo con la constante: SECONDPARTS.
Las fechas se muestran con los segundos enteros (si son enteros) o hasta las centésimas de segundo en otro caso.
El valor del índice utilizado en PutIndex se redondea (en lugar de usar floor) para evitar el problema que origina el tique.

git-svn-id: ​https://www.tol-project.org/svn/tolp/trunk@5984 be4846ae-f051-483a-831f-b64e7d08527f

Location:
tol/bbasic
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • tol/bbasic/dte.cpp

    rd4ea7bd r05d3c2d  
    268268 */
    269269//--------------------------------------------------------------------
    270     : year_(y), month_(m), day_(d), hour_(h), minute_(mi), second_(s)
     270    : year_(y), month_(m), day_(d), hour_(h), minute_(mi), second_(SECONDROUND(s))
    271271{
    272272}
  • tol/bbasic/dtealgeb.cpp

    rd4ea7bd r05d3c2d  
    3131BTraceInit("dtealgeb.cpp");
    3232
    33 static const BInt  dsByDay_  = 24*3600*100;
     33static const BInt  dsByDay_  = 24*3600*SECONDPARTS;
    3434static const BReal dsScale_  = 1.0/dsByDay_;
    3535static BDateFormat dateFormat_[] =
    … …  
    268268//  txt = BText("y")+year_+txt;
    269269
    270     if(second_+minute_+hour_             >0)
    271     {
    272       char theTime[64];
    273       BInt n = sprintf(theTime,"h%02di%02ds%06.3lf",hour_,minute_,second_);
    274       txt.Copy(theTime,n);
     270    if(second_+minute_+hour_>0)
     271    {
     272      if(round(second_)==second_)
     273      {
     274        char theTime[64];
     275        BInt n = sprintf(theTime,"h%02di%02ds%02d",hour_,minute_,int(round(second_)));
     276        txt.Copy(theTime,n);
     277      }
     278      else
     279      {
     280        char theTime[64];
     281        BInt n = sprintf(theTime,"h%02di%02ds%05.2lf",hour_,minute_,second_);
     282        txt.Copy(theTime,n);
     283      }
    275284    }
    276285    char theDate[64];
    … …  
    615624{
    616625        double idx = index;
    617   if(index == -300000) { *this = unknown_; return; }
    618   if(index <= -115782) { *this = begin_; return; }
    619   if(index >=  219147) { *this = end_; return; }
    620         double frac = modf(floor(index*dsByDay_)/dsByDay_, &idx);
    621 
     626        if(index == -300000) { *this = unknown_; return; }
     627        if(index <= -115782) { *this = begin_; return; }
     628        if(index >=  219147) { *this = end_; return; }
     629        double frac = modf(round(index*dsByDay_)/dsByDay_, &idx);
    622630        PutDayIndex(int(idx));
    623631        PutFraction(frac);
    … …  
    10031011    if(fraction>0)
    10041012    {
    1005         BInt fr = int(round(dsByDay_*fraction));
    1006         hour_ = 24*fr/dsByDay_;
    1007         fr -= hour_*dsByDay_/24;
    1008         minute_ = 24*60*fr/dsByDay_;
    1009         fr -= minute_*dsByDay_/(24*60);
    1010         second_ = BReal(24*3600*fr)/dsByDay_;
     1013                BInt fr = int(round(dsByDay_*fraction));
     1014                hour_ = int(floor(fr/double(round(dsByDay_/24))));
     1015                fr -= hour_*int(round(dsByDay_/24));
     1016                minute_ = int(floor(fr/double(round(dsByDay_/(24*60)))));
     1017                fr -= minute_*int(round(dsByDay_/(24*60)));
     1018                second_ = BReal(SECONDROUND(fr/double(round(dsByDay_/(24*60*60)))));
    10111019    }
    10121020    else
    10131021    {
    1014         hour_ = minute_ = 0;
    1015         second_ = 0.0;
     1022                hour_ = minute_ = 0;
     1023                second_ = 0.0;
    10161024    }
    10171025}
    … …  
    10821090    min = ((long int)(ss-sec))/60;
    10831091    IncMinute(min);
    1084     second_ = sec;
     1092    second_ = SECONDROUND(sec);
    10851093    /*BInt  s  = (ss>0)?1:-1;
    10861094    IncMinute(s*Div(s*ss,60));
  • tol/bbasic/tol_bdate.h

    rd4ea7bd r05d3c2d  
    2929// types
    3030//--------------------------------------------------------------------
    31 #define BMonth BInt
    32 #define JANUARY    1
     31#define BMonth  BInt
     32#define JANUARY    1
    3333#define FEBRUARY   2
    34 #define MARCH        3
    35 #define APRIL        4
    36 #define MAY            5
    37 #define JUNE         6
    38 #define JULY         7
    39 #define AUGUST     8
     34#define MARCH      3
     35#define APRIL      4
     36#define MAY        5
     37#define JUNE       6
     38#define JULY       7
     39#define AUGUST     8
    4040#define SEPTEMBER  9
    41 #define OCTOBER   10
     41#define OCTOBER   10
    4242#define NOVEMBER  11
    4343#define DECEMBER  12
    4444
    4545#define BWeekDay BInt
    46 #define MONDAY     1
    47 #define TUESDAY    2
    48 #define WEDNESDAY  3
    49 #define THURSDAY   4
    50 #define FRIDAY     5
    51 #define SATURDAY   6
    52 #define SUNDAY     7
     46#define MONDAY      1
     47#define TUESDAY     2
     48#define WEDNESDAY   3
     49#define THURSDAY    4
     50#define FRIDAY      5
     51#define SATURDAY    6
     52#define SUNDAY      7
    5353
    5454
    … …  
    6767#define DAYSCICLE1   (BInt)    365
    6868
     69#define SECONDPARTS 100
     70#define SECONDROUND(S) round(S*SECONDPARTS)/SECONDPARTS
    6971
    7072//--------------------------------------------------------------------
    … …  
    280282  void  PutMinute   (BInt    minute) { minute_  = minute; }
    281283  //! Sets second to the actual date
    282   void  PutSecond   (BReal   second) { second_  = second; }
     284  void  PutSecond   (BReal   second) { second_  = SECONDROUND(second); }
    283285  //! Sets hours, minutes and seconds corresponding to a given day fraction
    284286  void  PutFraction (BReal   fraction);
    … …  
    298300    hour_=h;
    299301    minute_=mi;
    300     second_=s;
     302    second_=SECONDROUND(s);
    301303  }
    302304  //! Sets date attributes from a Text \a txt (containig a date) and a DateFormat \a format
Note: See TracChangeset for help on using the changeset viewer.