From 29b7ce473cdf43f768f9288a5c21b5f02fd40e1f Mon Sep 17 00:00:00 2001 From: Chuck Hagenbuch Date: Mon, 2 Feb 2009 17:51:18 -0500 Subject: [PATCH] partial port of Time.php --- .../Date/Parser/Locale/Base/Repeater/Time.php | 119 ++++++++++++--------- 1 file changed, 70 insertions(+), 49 deletions(-) diff --git a/framework/Date_Parser/lib/Horde/Date/Parser/Locale/Base/Repeater/Time.php b/framework/Date_Parser/lib/Horde/Date/Parser/Locale/Base/Repeater/Time.php index 827be4e42..424311cf3 100644 --- a/framework/Date_Parser/lib/Horde/Date/Parser/Locale/Base/Repeater/Time.php +++ b/framework/Date_Parser/lib/Horde/Date/Parser/Locale/Base/Repeater/Time.php @@ -1,54 +1,46 @@ type = $hours; + break; + + case 3: + $this->type = Tick.new((t[0..0].to_i * 60 * 60) + (t[1..2].to_i * 60), true); + break; + + case 4: + $ambiguous = time =~ /:/ && t[0..0].to_i != 0 && t[0..1].to_i <= 12; + hours = t[0..1].to_i; + hours == 12 ? Tick.new(0 * 60 * 60 + t[2..3].to_i * 60, ambiguous) : Tick.new(hours * 60 * 60 + t[2..3].to_i * 60, ambiguous); + $this->type = $hours; + break; + + case 5: + $this->type = Tick.new(t[0..0].to_i * 60 * 60 + t[1..2].to_i * 60 + t[3..4].to_i, true); + break; + + case 6: + $ambiguous = time =~ /:/ && t[0..0].to_i != 0 && t[0..1].to_i <= 12; + $hours = t[0..1].to_i; + $hours == 12 ? Tick.new(0 * 60 * 60 + t[2..3].to_i * 60 + t[4..5].to_i, ambiguous) : Tick.new(hours * 60 * 60 + t[2..3].to_i * 60 + t[4..5].to_i, ambiguous); + $this->type = $hours; + break; + + default: + throw new Horde_Date_Parser_Exception('Time cannot exceed six digits'); + } + } # Return the next past or future Span for the time that this Repeater represents # pointer - Symbol representing which temporal direction to fetch the next day @@ -117,4 +109,33 @@ class Horde_Date_Parser_Locale_Base_Repeater_Time extends Horde_Date_Parser_Loca def to_s super << '-time-' << @type.to_s end -end \ No newline at end of file +end + +class Horde_Date_Tick +{ + public $time; + public $ambiguous; + + public function __construct($time, $ambiguous = false) + { + $this->time = $time; + $this->ambiguous = $ambiguous; + } + + public function mult($other) + { + return new Horde_Date_Tick($this->time * $other, $this->ambiguous); + } + + /* + def to_f + @time.to_f + end + */ + + public function __toString() + { + return $this->time . ($this->ambiguous ? '?' : ''); + } + +} \ No newline at end of file -- 2.11.0