Skip to content

Instantly share code, notes, and snippets.

@danilo04
Created April 5, 2011 03:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danilo04/902981 to your computer and use it in GitHub Desktop.
Save danilo04/902981 to your computer and use it in GitHub Desktop.
Par parser
<?php
class RelojEntry {
protected $numReloj;
protected $userId;
protected $date;
public function __set($name, $value) {
$this->$name = $value;
}
public function __get($name) {
return $this->$name;
}
}
class Reloj extends AppModel {
public $useTable = null;
protected $_contentRows = null;
protected $_entries = array();
public function loadFile($path) {
if (!file_exists($path)) {
return false;
}
$this->_contentRows = file($path);
}
public function getContentRows() {
return $this->_contentRows;
}
public function parseEntries() {
foreach ($this->getContentRows() as $row) {
$entry = new RelojEntry();
$columns = explode(",", $row);
$entry->numReloj = trim($columns[0]);
$entry->userId = trim($columns[3]);
$entry->date = trim($columns[9]) . '-' . trim($columns[8]) . '-' trim($columns[7]) . ' ' .
trim($columns[5]) . ':' . trim($columns[6]) . ':00';
$this->_entrys[] = $entry;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment