-<?php
-// vim: set expandtab tabstop=4 softtabstop=4 shiftwidth=4:
-// +--------------------------------------------------------------------+
-// | HORAS EXTRA |
-// +--------------------------------------------------------------------+
-// | Sistema de Horas Extra - Ministerio de Economía - Argentina |
-// +--------------------------------------------------------------------+
-// | Creado: lun abr 22 16:05:33 ART 2002 |
-// | Autor: Gonzalo Merayo <gmeray@mecon.gov.ar> |
-// +--------------------------------------------------------------------+
-//
-// $URL$
-// $Rev$
-// $Date$
-// $Author$
-//
+<?php /* vim: set binary expandtab tabstop=4 shiftwidth=4 textwidth=80:
+-------------------------------------------------------------------------------
+ Ministerio de Economía
+ meconlib
+-------------------------------------------------------------------------------
+This file is part of meconlib.
+
+meconlib is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2 of the License, or (at your option)
+any later version.
+
+meconlib is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License; if not,
+write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+Boston, MA 02111-1307 USA
+-------------------------------------------------------------------------------
+Creado: lun abr 22 16:05:33 ART 2002
+Autor: Gonzalo Merayo <gmeray@mecon.gov.ar>
+-------------------------------------------------------------------------------
+$Id$
+-----------------------------------------------------------------------------*/
-require_once "Date/Span.php";
+require_once 'Date/Span.php';
/**
- * Representa un Intervalo entre 2 horas del mismo dia
+ * Representa una hora.
*
* @package HE
* @abstract
* @version $Rev$
* @author Gonzalo Merayo <gmeray@mecon.gov.ar>
*/
-class Hora extends Date_Span {
+class MECON_Tiempo_Hora extends Date_Span {
- function set($str)
- {
- $str = strval($str);
- if (preg_match('/^\d+$/', $str)) {
- if ($str < 24) {
- $str = sprintf('0:%02d:00:00', $str );
- } elseif ($str == 24 or $str == 2400) {
- $str = '1:00:00:00';
- } elseif ($str < 2400) {
- switch (strlen($str)) {
+ function set
+ ($str) {
+ $str = strval($str);
+ if (preg_match('/^\d+$/', $str)) {
+ if ($str < 24) {
+ $str = sprintf('0:%02d:00:00', $str );
+ }
+ elseif ($str == 24 or $str == 2400) {
+ $str = '1:00:00:00';
+ }
+ elseif ($str < 2400) {
+ switch (strlen($str)) {
case 2:
- $str = sprintf('0:%02d:%02d:00', $str{0}, $str{1});
+ $str = sprintf('0:%02d:%02d:00', $str{0}, $str{1});
break;
case 3:
$str = sprintf('0:%02d:%02d:00', $str{0}, $str{1} . $str{2});
case 4:
$str = sprintf('0:%02d:%02d:00', $str{0} . $str{1}, $str{2} . $str{3});
break;
+ }
+ }
+ else {
+ return false;
}
- } else {
- return false;
}
- } elseif (preg_match('/^(\d{0,2})\D(\d{1,2})$/', $str, $m)) {
- if ($m[1] < 24 and $m[2] < 60) {
- $str = sprintf('0:%02d:%02d:00', $m[1], $m[2]);
- } elseif ($m[1] == 24 and $m[2] == 0) {
- $str = '1:00:00:00';
- } else {
- return false;
+ elseif (preg_match('/^(\d{0,2})\D(\d{1,2})$/', $str, $m)) {
+ if ($m[1] < 24 and $m[2] < 60) {
+ $str = sprintf('0:%02d:%02d:00', $m[1], $m[2]);
+ }
+ elseif ($m[1] == 24 and $m[2] == 0) {
+ $str = '1:00:00:00';
+ }
+ else {
+ return false;
+ }
}
- } elseif (preg_match('/^(\d{0,2})\D(\d{1,2})\D(\d{1,2})$/', $str, $m)) {
- if ($m[1] < 24 and $m[2] < 60 and $m[3] < 60) {
- $str = sprintf('0:%02d:%02d:%02d', $m[1], $m[2], $m[3]);
- } elseif ($m[1] == 24 and $m[2] == 0 and $m[3] == 0) {
- $str = '1:00:00:00';
- } else {
+ elseif (preg_match('/^(\d{0,2})\D(\d{1,2})\D(\d{1,2})$/', $str, $m)) {
+ if ($m[1] < 24 and $m[2] < 60 and $m[3] < 60) {
+ $str = sprintf('0:%02d:%02d:%02d', $m[1], $m[2], $m[3]);
+ }
+ elseif ($m[1] == 24 and $m[2] == 0 and $m[3] == 0) {
+ $str = '1:00:00:00';
+ }
+ else {
+ return false;
+ }
+ }
+ else {
return false;
}
- } else {
- return false;
+ $this->setFromString($str, "%D:%H:%M:%S");
+ return true;
}
- $this->setFromString($str, "%D:%H:%M:%S");
- return true;
- }
- function get()
- {
- return $this->format("%E:%M");
- }
+ function get
+ () {
+ return $this->format("%E:%M");
+ }
}
-// $Id$
-?>
+
+?>
\ No newline at end of file