Changeset 2509 in Sophya for trunk/SophyaLib/NTools
- Timestamp:
- Mar 15, 2004, 10:14:46 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/NTools/dates.cc
r2506 r2509 428 428 if (p[0] == '?' && (p[1] == '?' || p[1] == '/')) JJ = -1; 429 429 else { 430 if (!isdigit(p[0])) ParmError(PExcLongMessage(""));431 if (!isdigit(p[1]) && p[1] != '/') ParmError(PExcLongMessage(""));430 if (!isdigit(p[0])) throw ParmError(PExcLongMessage("")); 431 if (!isdigit(p[1]) && p[1] != '/') throw ParmError(PExcLongMessage("")); 432 432 JJ = atoi(p); 433 if (JJ <= 0) ParmError(PExcLongMessage(""));433 if (JJ <= 0) throw ParmError(PExcLongMessage("")); 434 434 } 435 435 436 436 if (p[1] == '/') p += 2; 437 437 else if (p[2] == '/') p+= 3; 438 else ParmError(PExcLongMessage(""));438 else throw ParmError(PExcLongMessage("")); 439 439 440 440 if (p[0] == '?' && (p[1] == '?' || p[1] == '/')) MM = -1; 441 441 else { 442 if (!isdigit(p[0])) ParmError(PExcLongMessage(""));443 if (!isdigit(p[1]) && p[1] != '/') ParmError(PExcLongMessage(""));442 if (!isdigit(p[0])) throw ParmError(PExcLongMessage("")); 443 if (!isdigit(p[1]) && p[1] != '/') throw ParmError(PExcLongMessage("")); 444 444 MM = atoi(p); 445 if (MM <= 0 || MM >12) ParmError(PExcLongMessage(""));445 if (MM <= 0 || MM >12) throw ParmError(PExcLongMessage("")); 446 446 } 447 447 448 448 if (p[1] == '/') p += 2; 449 449 else if (p[2] == '/') p+= 3; 450 else ParmError(PExcLongMessage(""));450 else throw ParmError(PExcLongMessage("")); 451 451 452 452 if (p[0] == '?') AA = -1; 453 453 else { 454 if (!isdigit(p[0])) ParmError(PExcLongMessage(""));455 if (!isdigit(p[1])) ParmError(PExcLongMessage(""));454 if (!isdigit(p[0])) throw ParmError(PExcLongMessage("")); 455 if (!isdigit(p[1])) throw ParmError(PExcLongMessage("")); 456 456 AA = atoi(p); 457 457 if (AA < 100 && AA >= 0 && date[6] != '0') AA += 1900; 458 458 } 459 459 460 if (AA > 0 && MM > 0 && JJ > 0 && JJ > MonthDays(MM,AA)) ParmError(PExcLongMessage("")); 460 if (AA > 0 && MM > 0 && JJ > 0 && JJ > MonthDays(MM,AA)) 461 throw ParmError(PExcLongMessage("")); 461 462 462 463 } else if (strlen(date)==4) { // Code EROS de date 463 464 if (date[0] == '?') AA = -1; 464 465 else { 465 if (!isdigit(date[0])) ParmError(PExcLongMessage(""));466 if (!isdigit(date[0])) throw ParmError(PExcLongMessage("")); 466 467 AA = 1990 + date[0] - '0'; 467 468 } … … 469 470 if (date[1] == '?') MM = -1; 470 471 else { 471 if (!isalpha(date[1])) ParmError(PExcLongMessage(""));472 if (!isalpha(date[1])) throw ParmError(PExcLongMessage("")); 472 473 if (islower(date[1])) 473 474 MM = date[1] - 'a' + 1; 474 475 else 475 476 MM = date[1] - 'A' + 1; 476 if (MM<1 || MM>12) ParmError(PExcLongMessage(""));477 if (MM<1 || MM>12) throw ParmError(PExcLongMessage("")); 477 478 } 478 479 479 480 if (date[2] == '?' && date[3] == '?') JJ = -1; 480 481 else { 481 if (!isdigit(date[2])) ParmError(PExcLongMessage(""));482 if (!isdigit(date[3])) ParmError(PExcLongMessage(""));482 if (!isdigit(date[2])) throw ParmError(PExcLongMessage("")); 483 if (!isdigit(date[3])) throw ParmError(PExcLongMessage("")); 483 484 JJ = atoi(date+2); 484 485 } 485 486 486 if (AA > 0 && MM > 0 && JJ > 0 && JJ > MonthDays(MM,AA)) ParmError(PExcLongMessage("")); 487 if (AA > 0 && MM > 0 && JJ > 0 && JJ > MonthDays(MM,AA)) 488 throw ParmError(PExcLongMessage("")); 487 489 nuit = 1; 488 } else ParmError(PExcLongMessage("")); // Mauvaise longueur490 } else throw ParmError(PExcLongMessage("")); // Mauvaise longueur 489 491 } else { // Pas de date 490 492 JJ = MM = AA = -1; … … 495 497 if (p[0] == '?' && (p[1] == '?' || p[1] == ':')) hh = -1; 496 498 else { 497 if (!isdigit(p[0])) ParmError(PExcLongMessage(""));498 if (!isdigit(p[1]) && p[1] != ':') ParmError(PExcLongMessage(""));499 if (!isdigit(p[0])) throw ParmError(PExcLongMessage("")); 500 if (!isdigit(p[1]) && p[1] != ':') throw ParmError(PExcLongMessage("")); 499 501 hh = atoi(p); 500 502 } … … 502 504 if (p[1] == ':') p += 2; 503 505 else if (p[2] == ':') p+= 3; 504 else ParmError(PExcLongMessage(""));506 else throw ParmError(PExcLongMessage("")); 505 507 506 508 if (p[0] == '?' && (p[1] == '?' || p[1] == ':')) mm = -1; 507 509 else { 508 if (!isdigit(p[0])) ParmError(PExcLongMessage(""));509 if (!isdigit(p[1]) && p[1] != '/') ParmError(PExcLongMessage(""));510 if (!isdigit(p[0])) throw ParmError(PExcLongMessage("")); 511 if (!isdigit(p[1]) && p[1] != '/') throw ParmError(PExcLongMessage("")); 510 512 mm = atoi(p); 511 513 } … … 513 515 if (p[1] == ':') p += 2; 514 516 else if (p[2] == ':') p+= 3; 515 else ParmError(PExcLongMessage(""));517 else throw ParmError(PExcLongMessage("")); 516 518 517 519 if (p[0] == '?') ss = -1; 518 520 else { 519 if (!isdigit(p[0])) ParmError(PExcLongMessage(""));521 if (!isdigit(p[0])) throw ParmError(PExcLongMessage("")); 520 522 ss = atoi(p); 521 523 } … … 578 580 579 581 if (dt.AA != -1) { 580 if (dt.AA < 1990 || dt.AA > 2016) ParmError(PExcLongMessage(""));582 if (dt.AA < 1990 || dt.AA > 2016) throw ParmError(PExcLongMessage("")); 581 583 int i = dt.AA - 1990; 582 584 if (i<10) … … 764 766 //-- 765 767 { 766 if (a.UndetTime() != b.UndetTime()) ParmError(PExcLongMessage(""));767 if (a.UndetDate() != b.UndetDate()) ParmError(PExcLongMessage(""));768 if (a.UndetTime() != b.UndetTime()) throw ParmError(PExcLongMessage("")); 769 if (a.UndetDate() != b.UndetDate()) throw ParmError(PExcLongMessage("")); 768 770 return a.GetDays() - b.GetDays(); 769 771 }
Note:
See TracChangeset
for help on using the changeset viewer.