Example #1
0
 public function action_get_archive($year, $month = NULL)
 {
     if ($month) {
         $start = DateTime::createFromFormat('Y-m-d', sprintf('%s-%s-%s', $year, $month, 1));
         $end = clone $start;
         $end->add(new \DateInterval('P1M'));
         $title = $start->format('Y-m');
     } else {
         $start = DateTime::createFromFormat('Y-m-d', sprintf('%s-%s-%s', $year, 1, 1));
         $end = clone $start;
         $end->add(new \DateInterval('P1Y'));
         $title = $start->format('Y');
     }
     return self::create_posts("archive » {$title}", Posts::archive($start, $end));
 }