Project

General

Profile

« Previous | Next » 

Revision ef6a4ce9

Added by Andreas Kohlbecker over 4 years ago

ref #8245 stripping trailing zeros in description element time priods, with test

View differences:

modules/cdm_dataportal/cdm_api/cdm_api.module
429 429
 * @return
430 430
 *  the formatted string representation of the $datetime
431 431
 */
432
function format_datetime($datetime, $format = 'Y-m-d H:i:s'){
432
function format_datetime($datetime, $format = 'Y-m-d H:i:s', $strip_zeros = true){
433 433
  return date($format, strtotime($datetime));
434 434
}
435 435

  
......
540 540
    $d = partialToDay($partial);
541 541
  }
542 542

  
543
  $y = $y ? $y : '00';
543
  $y = $y ? $y : '0000';
544 544
  $m = $m ? $m : '00';
545 545
  $d = $d ? $d : '00';
546 546

  
547 547
  $date = '';
548 548

  
549
  if ($y == '00' && $stripZeros) {
549
  if ($y == '0000' && $stripZeros && $m == '00' && $d == '00') {
550 550
    return '';
551 551
  }
552 552
  else {
553 553
    $date = $y;
554 554
  }
555 555

  
556
  if ($m == '00' && $stripZeros) {
556
  if ($m == '00' && $stripZeros && $d == '00') {
557 557
    return $date;
558 558
  }
559 559
  else {
modules/cdm_dataportal/includes/descriptions.inc
460 460

  
461 461
  $timescope_markup = '';
462 462
  if(isset($element->timeperiod)){
463
    $timescope_markup = ' ' . timePeriodToString($element->timeperiod, false);
463
    $timescope_markup = ' ' . timePeriodToString($element->timeperiod, true);
464 464
  }
465 465

  
466 466
  // handle the special case were the TextData is used as container for original source with name
src/test/java/eu/etaxonomy/dataportal/selenium/tests/reference/DescriptionElementsTest.java
52 52

  
53 53
        FeatureBlock fb = p.getFeatureBlockAt(0, "biology-and-ecology", "div", "span");
54 54
        assertNotNull(fb);
55
        assertEquals(2, fb.getFeatureBlockElements().size());
56
        assertEquals("Flowers with white blossoms on Testisland A. 00-05-00 to 00-06-00 (Lem, New Species in the solar system: p.99)", fb.getFeatureBlockElements().get(0).getText());
55
        assertEquals(3, fb.getFeatureBlockElements().size());
56
        assertEquals("Flowers with white blossoms on Testisland A. 0000-05 to 0000-06 (Lem, New Species in the solar system: p.99)", fb.getFeatureBlockElements().get(0).getText());
57 57
        assertEquals("Flowers with white blossoms on Testisland B. Mai to June (Lem, New Species in the solar system: p.99)", fb.getFeatureBlockElements().get(1).getText());
58
        assertEquals("Flowers with white blossoms on Testisland C. 2000 to 2000-05", fb.getFeatureBlockElements().get(2).getText());
58 59

  
59 60
    }
60 61

  

Also available in: Unified diff