Changeset 3063


Ignore:
Timestamp:
Jan 6, 2013, 3:29:20 PM (8 years ago)
Author:
roux
Message:

better handle weeks during change of year for plots

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpc/trunk/project/apps/frontend/modules/plot/actions/components.class.php

    r3055 r3063  
    2121      else $last_year = $date - 32054400;
    2222      $date_debut = date('Y-m-d', $last_year);
    23       $annee0 = date('Y', $last_year); $sem0 = date('W', $last_year);
    24       if ($sem >= 52 && date('n', $date) == 1) $sem = 0;
    25       if ($sem0 >= 52 && $sem <= 1) {
    26         $sem0 = 0;
    27         $annee0 += 1;
     23      $annee0 = date('o', $last_year); $sem0 = date('W', $last_year);
     24      if ($sem > 51 && date('n', $date) == 1) $sem = 0;
     25      if ($sem < 2 && $annee != date('o', $date)) {
     26        $annee = date('o', $date);
     27        $sem0 -= 1;
    2828      }
    2929      $n_weeks = ($annee - $annee0)*53 + $sem - $sem0 + 1;
     
    232232
    233233  public static function getLabelsSemaines($n_weeks, $annee, $sem) {
    234     if ($sem > 1 && $sem <= 51) $an = $annee + 1;
    235     else $an = $annee;
    236     $hashmap = array( '3'  => "Jan ".sprintf('%02d', $an-2000), '6'  => " Fév", '10' => " Mar", '15' => "Avr",
     234    if ($sem > 1 && $sem <= 52) $annee += 1;
     235    $hashmap = array( '3'  => "Jan ".sprintf('%02d', $annee-2000), '6'  => " Fév", '10' => " Mar", '15' => "Avr",
    237236                      '19' => " Mai", '24' => "Juin", '28' => "Juil", '33' => "Août",
    238237                      '38' => "Sept", '42' => " Oct", '47' => "Nov", '52' => "Déc");
     
    242241      if (isset($hashmap[$index]) && !(($index == 3) && ($sem < 3 && $sem > 1))) $labels[$i] = $hashmap[$index];
    243242    }
    244     if ($sem < 3 && $sem != 0) $labels[54] = "Jan";
     243    if ($n_weeks > 54 && $sem < 3 && $sem != 0) $labels[55] = "Jan";
    245244    return $labels;
    246245  }
Note: See TracChangeset for help on using the changeset viewer.