1 <?php /* vim: set binary expandtab tabstop=4 shiftwidth=4 textwidth=80:
2 -------------------------------------------------------------------------------
3 Ministerio de EconomÃa
5 -------------------------------------------------------------------------------
6 This file is part of meconlib.
8 meconlib is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 2 of the License, or (at your option)
13 meconlib is distributed in the hope that it will be useful, but WITHOUT
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License; if not,
18 write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
19 Boston, MA 02111-1307 USA
20 -------------------------------------------------------------------------------
21 Creado: lun abr 22 16:05:33 ART 2002
22 Autor: Gonzalo Merayo <gmeray@mecon.gov.ar>
23 -------------------------------------------------------------------------------
25 -----------------------------------------------------------------------------*/
27 require_once 'Date/Span.php';
30 * Representa una hora.
35 * @author Gonzalo Merayo <gmeray@mecon.gov.ar>
37 class MECON_Tiempo_Hora extends Date_Span {
42 if (preg_match('/^\d+$/', $str)) {
44 $str = sprintf('0:%02d:00:00', $str );
45 } elseif ($str == 24 or $str == 2400) {
47 } elseif ($str < 2400) {
48 switch (strlen($str)) {
50 $str = sprintf('0:%02d:%02d:00', $str{0}, $str{1});
53 $str = sprintf('0:%02d:%02d:00', $str{0}, $str{1} . $str{2});
56 $str = sprintf('0:%02d:%02d:00', $str{0} . $str{1}, $str{2} . $str{3});
62 } elseif (preg_match('/^(\d{0,2})\D(\d{1,2})$/', $str, $m)) {
63 if ($m[1] < 24 and $m[2] < 60) {
64 $str = sprintf('0:%02d:%02d:00', $m[1], $m[2]);
65 } elseif ($m[1] == 24 and $m[2] == 0) {
70 } elseif (preg_match('/^(\d{0,2})\D(\d{1,2})\D(\d{1,2})$/', $str, $m)) {
71 if ($m[1] < 24 and $m[2] < 60 and $m[3] < 60) {
72 $str = sprintf('0:%02d:%02d:%02d', $m[1], $m[2], $m[3]);
73 } elseif ($m[1] == 24 and $m[2] == 0 and $m[3] == 0) {
81 $this->setFromString($str, "%D:%H:%M:%S");
87 return $this->format("%E:%M");