Changeset 2506 in Sophya for trunk/SophyaLib/NTools/dates.cc
- Timestamp:
- Mar 15, 2004, 5:46:56 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/NTools/dates.cc
r2322 r2506 44 44 #endif 45 45 SetZone(p); 46 END_CONSTRUCTOR;47 46 } 48 47 … … 54 53 { 55 54 SetZone(nom); 56 END_CONSTRUCTOR57 55 } 58 56 … … 94 92 dstStopMonth = Date::mois_Mars; 95 93 dstOffset = 1; 96 } else THROW(parmErr);94 } else throw ParmError("TimeZone::SetZone() "); 97 95 } 98 96 … … 104 102 { 105 103 Date dt = date; 106 if (dt.MM < 0 || dt.JJ < 0) THROW(inconsistentErr)104 if (dt.MM < 0 || dt.JJ < 0) throw ParmError(PExcLongMessage("")); 107 105 if (dt.hh >= 0) dt += gmtOffset/24.0; // date "fictive" en local d'hiver 108 106 else dt.ss = dt.hh = dt.mm = 0; // minuit local si heure indeterminee … … 185 183 //-- 186 184 { 187 if (mois<1 || mois>12) THROW(inconsistentErr);185 if (mois<1 || mois>12) throw ParmError(PExcLongMessage("")); 188 186 189 187 switch(mois) { … … 265 263 //-- 266 264 { 267 if (UndetTime() && !AllUndetTime()) THROW(inconsistentErr);268 if (UndetDate() && !AllUndetDate()) THROW(inconsistentErr);265 if (UndetTime() && !AllUndetTime()) throw ParmError(PExcLongMessage("")); 266 if (UndetDate() && !AllUndetDate()) throw ParmError(PExcLongMessage("")); 269 267 double t=0; 270 268 if (!UndetDate()) { … … 341 339 ss = TM->tm_sec; 342 340 nuit = 0; 343 END_CONSTRUCTOR344 341 } 345 342 … … 351 348 : JJ(J), MM(M), AA(A), hh(h), mm(m), ss(s), timeZone(gTimeZone), nuit(0) 352 349 { 353 END_CONSTRUCTOR354 350 } 355 351 … … 364 360 { 365 361 Set(t); 366 END_CONSTRUCTOR367 362 } 368 363 … … 388 383 { 389 384 Set(date,heure,tOpt); 390 END_CONSTRUCTOR391 385 } 392 386 … … 403 397 { 404 398 Set(date,heure,tOpt); 405 END_CONSTRUCTOR406 399 } 407 400 … … 435 428 if (p[0] == '?' && (p[1] == '?' || p[1] == '/')) JJ = -1; 436 429 else { 437 if (!isdigit(p[0])) THROW(inconsistentErr);438 if (!isdigit(p[1]) && p[1] != '/') THROW(inconsistentErr);430 if (!isdigit(p[0])) ParmError(PExcLongMessage("")); 431 if (!isdigit(p[1]) && p[1] != '/') ParmError(PExcLongMessage("")); 439 432 JJ = atoi(p); 440 if (JJ <= 0) THROW(inconsistentErr);433 if (JJ <= 0) ParmError(PExcLongMessage("")); 441 434 } 442 435 443 436 if (p[1] == '/') p += 2; 444 437 else if (p[2] == '/') p+= 3; 445 else THROW(inconsistentErr);438 else ParmError(PExcLongMessage("")); 446 439 447 440 if (p[0] == '?' && (p[1] == '?' || p[1] == '/')) MM = -1; 448 441 else { 449 if (!isdigit(p[0])) THROW(inconsistentErr);450 if (!isdigit(p[1]) && p[1] != '/') THROW(inconsistentErr);442 if (!isdigit(p[0])) ParmError(PExcLongMessage("")); 443 if (!isdigit(p[1]) && p[1] != '/') ParmError(PExcLongMessage("")); 451 444 MM = atoi(p); 452 if (MM <= 0 || MM >12) THROW(inconsistentErr);445 if (MM <= 0 || MM >12) ParmError(PExcLongMessage("")); 453 446 } 454 447 455 448 if (p[1] == '/') p += 2; 456 449 else if (p[2] == '/') p+= 3; 457 else THROW(inconsistentErr);450 else ParmError(PExcLongMessage("")); 458 451 459 452 if (p[0] == '?') AA = -1; 460 453 else { 461 if (!isdigit(p[0])) THROW(inconsistentErr);462 if (!isdigit(p[1])) THROW(inconsistentErr);454 if (!isdigit(p[0])) ParmError(PExcLongMessage("")); 455 if (!isdigit(p[1])) ParmError(PExcLongMessage("")); 463 456 AA = atoi(p); 464 457 if (AA < 100 && AA >= 0 && date[6] != '0') AA += 1900; 465 458 } 466 459 467 if (AA > 0 && MM > 0 && JJ > 0 && JJ > MonthDays(MM,AA)) THROW(inconsistentErr);460 if (AA > 0 && MM > 0 && JJ > 0 && JJ > MonthDays(MM,AA)) ParmError(PExcLongMessage("")); 468 461 469 462 } else if (strlen(date)==4) { // Code EROS de date 470 463 if (date[0] == '?') AA = -1; 471 464 else { 472 if (!isdigit(date[0])) THROW(inconsistentErr);465 if (!isdigit(date[0])) ParmError(PExcLongMessage("")); 473 466 AA = 1990 + date[0] - '0'; 474 467 } … … 476 469 if (date[1] == '?') MM = -1; 477 470 else { 478 if (!isalpha(date[1])) THROW(inconsistentErr);471 if (!isalpha(date[1])) ParmError(PExcLongMessage("")); 479 472 if (islower(date[1])) 480 473 MM = date[1] - 'a' + 1; 481 474 else 482 475 MM = date[1] - 'A' + 1; 483 if (MM<1 || MM>12) THROW(inconsistentErr);476 if (MM<1 || MM>12) ParmError(PExcLongMessage("")); 484 477 } 485 478 486 479 if (date[2] == '?' && date[3] == '?') JJ = -1; 487 480 else { 488 if (!isdigit(date[2])) THROW(inconsistentErr);489 if (!isdigit(date[3])) THROW(inconsistentErr);481 if (!isdigit(date[2])) ParmError(PExcLongMessage("")); 482 if (!isdigit(date[3])) ParmError(PExcLongMessage("")); 490 483 JJ = atoi(date+2); 491 484 } 492 485 493 if (AA > 0 && MM > 0 && JJ > 0 && JJ > MonthDays(MM,AA)) THROW(inconsistentErr);486 if (AA > 0 && MM > 0 && JJ > 0 && JJ > MonthDays(MM,AA)) ParmError(PExcLongMessage("")); 494 487 nuit = 1; 495 } else THROW(inconsistentErr); // Mauvaise longueur488 } else ParmError(PExcLongMessage("")); // Mauvaise longueur 496 489 } else { // Pas de date 497 490 JJ = MM = AA = -1; … … 502 495 if (p[0] == '?' && (p[1] == '?' || p[1] == ':')) hh = -1; 503 496 else { 504 if (!isdigit(p[0])) THROW(inconsistentErr);505 if (!isdigit(p[1]) && p[1] != ':') THROW(inconsistentErr);497 if (!isdigit(p[0])) ParmError(PExcLongMessage("")); 498 if (!isdigit(p[1]) && p[1] != ':') ParmError(PExcLongMessage("")); 506 499 hh = atoi(p); 507 500 } … … 509 502 if (p[1] == ':') p += 2; 510 503 else if (p[2] == ':') p+= 3; 511 else THROW(inconsistentErr);504 else ParmError(PExcLongMessage("")); 512 505 513 506 if (p[0] == '?' && (p[1] == '?' || p[1] == ':')) mm = -1; 514 507 else { 515 if (!isdigit(p[0])) THROW(inconsistentErr);516 if (!isdigit(p[1]) && p[1] != '/') THROW(inconsistentErr);508 if (!isdigit(p[0])) ParmError(PExcLongMessage("")); 509 if (!isdigit(p[1]) && p[1] != '/') ParmError(PExcLongMessage("")); 517 510 mm = atoi(p); 518 511 } … … 520 513 if (p[1] == ':') p += 2; 521 514 else if (p[2] == ':') p+= 3; 522 else THROW(inconsistentErr);515 else ParmError(PExcLongMessage("")); 523 516 524 517 if (p[0] == '?') ss = -1; 525 518 else { 526 if (!isdigit(p[0])) THROW(inconsistentErr);519 if (!isdigit(p[0])) ParmError(PExcLongMessage("")); 527 520 ss = atoi(p); 528 521 } … … 585 578 586 579 if (dt.AA != -1) { 587 if (dt.AA < 1990 || dt.AA > 2016) THROW(inconsistentErr);580 if (dt.AA < 1990 || dt.AA > 2016) ParmError(PExcLongMessage("")); 588 581 int i = dt.AA - 1990; 589 582 if (i<10) … … 771 764 //-- 772 765 { 773 if (a.UndetTime() != b.UndetTime()) THROW(inconsistentErr);774 if (a.UndetDate() != b.UndetDate()) THROW(inconsistentErr);766 if (a.UndetTime() != b.UndetTime()) ParmError(PExcLongMessage("")); 767 if (a.UndetDate() != b.UndetDate()) ParmError(PExcLongMessage("")); 775 768 return a.GetDays() - b.GetDays(); 776 769 }
Note:
See TracChangeset
for help on using the changeset viewer.