Esempio n. 1
0
 public function isTomorrow()
 {
     return $this->mysqlDate() == Date::fromUnixTime(strtotime('today +1 day'))->mysqlDate();
 }
Esempio n. 2
0
 /**
  * @param int $id_node
  * @param int $uid
  * @param filename $group
  * @param filename $zone
  * @param int $etat
  * @param int $rank
  * @param array $data
  * @return int id_node
  * @throws Exception
  * create node, if id_node is specified it replace the existing
  */
 protected function createNode($id_node = null, $uid = null, $group = null, $zone = null, $etat = 0, $rank = 500, $data = array(), $date_publication = null)
 {
     if (!$rank) {
         $rank = 500;
     }
     if (!$etat) {
         $etat = 0;
     }
     if (!trim($this->type_node)) {
         throw new Exception('type_node is missing', 500);
     }
     try {
         $tid = Db::startTransaction();
         $permission = new Permission($this->O);
         $gid = null;
         if ($group) {
             if ($permission->existGroup($group)) {
                 $gid = $permission->idGroup($group);
             }
         }
         $zid = null;
         if ($zone) {
             if ($permission->existGroup($group)) {
                 $zid = $permission->idGroup($zone);
             }
         }
         $date_creation = Date::fromUnixTime(time())->mysqlDateTime();
         if (!$date_publication) {
             $date_publication = $date_creation;
         }
         $d = array('type_node' => $this->type_node, 'uid' => $uid, 'gid' => $gid, 'zid' => $zid, 'rank' => $rank, 'etat' => $etat, 'data' => null, 'date_creation' => $date_creation, 'date_modification' => $date_creation, 'date_publication' => $date_publication);
         $req = $this->dbNode->duplicate();
         $r = null;
         if ($id_node) {
             $r = $this->updateNode($id_node, $d);
         }
         if (!$r) {
             if ($id_node) {
                 $d['id_node'] = $id_node;
             }
             if ($id = $req->insert($d)) {
                 $id_node = $id_node ? $id_node : $id;
             }
         }
         if ($id_node) {
             $this->updateNodeDataBlob($id_node, 'node', $data);
         }
         Db::endTransaction($tid);
         return $id_node;
     } catch (\Exception $e) {
         Db::rollback();
         throw $e;
     }
 }
Esempio n. 3
0
 /**
  * @covers Fp\Core\Date::format
  * @todo   Implement testFormat().
  */
 public function testFormat()
 {
     $this->assertEquals('25/12/1998 01:00', \Fp\Core\Date::fromUnixTime(914544000)->format('d/m/Y h:i'));
 }