comparison libinterp/corefcn/time.cc @ 20616:fd0efcdb3718

use new string_value method to handle value extraction errors * dirfns.cc, file-io.cc, gammainc.cc, help.cc, load-path.cc, octave-link.cc, qz.cc, regexp.cc, strfns.cc, syscalls.cc, time.cc, variables.cc: Use new string_value method.
author John W. Eaton <jwe@octave.org>
date Thu, 08 Oct 2015 19:00:51 -0400
parents f90c8372b7ba
children
comparison
equal deleted inserted replaced
20615:729a85dafba8 20616:fd0efcdb3718
471 { 471 {
472 octave_value retval; 472 octave_value retval;
473 473
474 if (args.length () == 2) 474 if (args.length () == 2)
475 { 475 {
476 if (args(0).is_string ()) 476 std::string fmt = args(0).string_value ("strftime: FMT must be a string");
477
478 octave_scalar_map map = args(1).scalar_map_value ();
479
480 if (! error_state)
477 { 481 {
478 std::string fmt = args(0).string_value (); 482 octave_base_tm tm = extract_tm (map);
479
480 octave_scalar_map map = args(1).scalar_map_value ();
481 483
482 if (! error_state) 484 if (! error_state)
483 { 485 retval = tm.strftime (fmt);
484 octave_base_tm tm = extract_tm (map);
485
486 if (! error_state)
487 retval = tm.strftime (fmt);
488 else
489 error ("strftime: invalid TM_STRUCT argument");
490 }
491 else 486 else
492 error ("strftime: TM_STRUCT must be a structure"); 487 error ("strftime: invalid TM_STRUCT argument");
493 } 488 }
494 else 489 else
495 error ("strftime: FMT must be a string"); 490 error ("strftime: TM_STRUCT must be a structure");
496 } 491 }
497 else 492 else
498 print_usage (); 493 print_usage ();
499 494
500 return retval; 495 return retval;
527 { 522 {
528 octave_value_list retval; 523 octave_value_list retval;
529 524
530 if (args.length () == 2) 525 if (args.length () == 2)
531 { 526 {
532 if (args(0).is_string ()) 527 std::string str = args(0).string_value ("strptime: argument STR must be a string");
533 { 528
534 std::string str = args(0).string_value (); 529 std::string fmt = args(1).string_value ("strptime: FMT must be a string");
535 530
536 if (args(1).is_string ()) 531 octave_strptime t (str, fmt);
537 { 532
538 std::string fmt = args(1).string_value (); 533 retval(1) = t.characters_converted ();
539 534 retval(0) = octave_value (mk_tm_map (t));
540 octave_strptime t (str, fmt);
541
542 retval(1) = t.characters_converted ();
543 retval(0) = octave_value (mk_tm_map (t));
544 }
545 else
546 error ("strptime: FMT must be a string");
547 }
548 else
549 error ("strptime: argument STR must be a string");
550 } 535 }
551 else 536 else
552 print_usage (); 537 print_usage ();
553 538
554 return retval; 539 return retval;