Changeset 05d3c2d in tol
- Timestamp:
- Aug 12, 2013, 2:46:25 PM (13 years ago)
- Branches:
- 1941-docker-image-to-test, devel, master
- Children:
- 88d8fd9
- Parents:
- d4ea7bd
- Location:
- tol/bbasic
- Files:
-
- 3 edited
-
dte.cpp (modified) (1 diff)
-
dtealgeb.cpp (modified) (5 diffs)
-
tol_bdate.h (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tol/bbasic/dte.cpp
rd4ea7bd r05d3c2d 268 268 */ 269 269 //-------------------------------------------------------------------- 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)) 271 271 { 272 272 } -
tol/bbasic/dtealgeb.cpp
rd4ea7bd r05d3c2d 31 31 BTraceInit("dtealgeb.cpp"); 32 32 33 static const BInt dsByDay_ = 24*3600* 100;33 static const BInt dsByDay_ = 24*3600*SECONDPARTS; 34 34 static const BReal dsScale_ = 1.0/dsByDay_; 35 35 static BDateFormat dateFormat_[] = … … 268 268 // txt = BText("y")+year_+txt; 269 269 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 } 275 284 } 276 285 char theDate[64]; … … 615 624 { 616 625 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); 622 630 PutDayIndex(int(idx)); 623 631 PutFraction(frac); … … 1003 1011 if(fraction>0) 1004 1012 { 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))))); 1011 1019 } 1012 1020 else 1013 1021 { 1014 hour_ = minute_ = 0;1015 second_ = 0.0;1022 hour_ = minute_ = 0; 1023 second_ = 0.0; 1016 1024 } 1017 1025 } … … 1082 1090 min = ((long int)(ss-sec))/60; 1083 1091 IncMinute(min); 1084 second_ = sec;1092 second_ = SECONDROUND(sec); 1085 1093 /*BInt s = (ss>0)?1:-1; 1086 1094 IncMinute(s*Div(s*ss,60)); -
tol/bbasic/tol_bdate.h
rd4ea7bd r05d3c2d 29 29 // types 30 30 //-------------------------------------------------------------------- 31 #define BMonth BInt32 #define JANUARY 131 #define BMonth BInt 32 #define JANUARY 1 33 33 #define FEBRUARY 2 34 #define MARCH 335 #define APRIL 436 #define MAY 537 #define JUNE 638 #define JULY 739 #define AUGUST 834 #define MARCH 3 35 #define APRIL 4 36 #define MAY 5 37 #define JUNE 6 38 #define JULY 7 39 #define AUGUST 8 40 40 #define SEPTEMBER 9 41 #define OCTOBER 1041 #define OCTOBER 10 42 42 #define NOVEMBER 11 43 43 #define DECEMBER 12 44 44 45 45 #define BWeekDay BInt 46 #define MONDAY 147 #define TUESDAY 248 #define WEDNESDAY 349 #define THURSDAY 450 #define FRIDAY 551 #define SATURDAY 652 #define SUNDAY 746 #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 53 53 54 54 … … 67 67 #define DAYSCICLE1 (BInt) 365 68 68 69 #define SECONDPARTS 100 70 #define SECONDROUND(S) round(S*SECONDPARTS)/SECONDPARTS 69 71 70 72 //-------------------------------------------------------------------- … … 280 282 void PutMinute (BInt minute) { minute_ = minute; } 281 283 //! Sets second to the actual date 282 void PutSecond (BReal second) { second_ = second; }284 void PutSecond (BReal second) { second_ = SECONDROUND(second); } 283 285 //! Sets hours, minutes and seconds corresponding to a given day fraction 284 286 void PutFraction (BReal fraction); … … 298 300 hour_=h; 299 301 minute_=mi; 300 second_= s;302 second_=SECONDROUND(s); 301 303 } 302 304 //! 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.
