2 // vim: set expandtab tabstop=4 softtabstop=4 shiftwidth=4:
3 // +--------------------------------------------------------------------+
5 // +--------------------------------------------------------------------+
6 // | Sistema de Horas Extra - Ministerio de EconomÃa - Argentina |
7 // +--------------------------------------------------------------------+
8 // | Creado: lun abr 22 16:05:33 ART 2002 |
9 // | Autor: Gonzalo Merayo <gmeray@mecon.gov.ar> |
10 // +--------------------------------------------------------------------+
18 require_once "Time/Span.php";
21 * Representa un Intervalo entre 2 horas del mismo dia
26 * @author Gonzalo Merayo <gmeray@mecon.gov.ar>
28 class Hora extends Time_Span {
33 if (preg_match('/^\d+$/', $str)) {
35 $str = sprintf('0:%02d:00:00', $str );
36 } elseif ($str == 24 or $str == 2400) {
38 } elseif ($str < 2400) {
39 switch (strlen($str)) {
41 $str = sprintf('0:%02d:%02d:00', $str{0}, $str{1});
44 $str = sprintf('0:%02d:%02d:00', $str{0}, $str{1} . $str{2});
47 $str = sprintf('0:%02d:%02d:00', $str{0} . $str{1}, $str{2} . $str{3});
53 } elseif (preg_match('/^(\d{0,2})\D(\d{1,2})$/', $str, $m)) {
54 if ($m[1] < 24 and $m[2] < 60) {
55 $str = sprintf('0:%02d:%02d:00', $m[1], $m[2]);
56 } elseif ($m[1] == 24 and $m[2] == 0) {
61 } elseif (preg_match('/^(\d{0,2})\D(\d{1,2})\D(\d{1,2})$/', $str, $m)) {
62 if ($m[1] < 24 and $m[2] < 60 and $m[3] < 60) {
63 $str = sprintf('0:%02d:%02d:%02d', $m[1], $m[2], $m[3]);
64 } elseif ($m[1] == 24 and $m[2] == 0 and $m[3] == 0) {
72 $this->setFromString($str, "%D:%H:%M:%S");
78 return $this->format("%E:%M");