[hermes] future dates are marked as bygone
Jens A. Tkotz
jens at peino.de
Tue Jan 4 08:12:34 PST 2005
Hello,
the problem lies in framework/Form/Form.php in method getAgo().
So its not only a hermes issue.
its a little unnice that PEARs dateDiff only returns the absolute
number of days
between two dates. so you need to call a second method.
unified patch below.
I also added a little catch for the case that an error occured.
Regards,
Jens
Index: Form.php
===================================================================
RCS file: /repository/framework/Form/Form.php,v
retrieving revision 1.308
diff -u -r1.308 Form.php
--- Form.php 3 Jan 2005 13:09:05 -0000 1.308
+++ Form.php 4 Jan 2005 15:21:34 -0000
@@ -2313,15 +2313,27 @@
function getAgo($timestamp)
{
require_once 'Date/Calc.php';
- $ago = Date_Calc::dateDiff(date('j', $timestamp), date('n',
$timestamp), date('Y', $timestamp),
+ $diffdays = Date_Calc::dateDiff(date('j', $timestamp), date('n',
$timestamp), date('Y', $timestamp),
date('j'), date('n'), date('Y'));
- if ($ago == 0) {
+ /* An error occured */
+ if ($diffdays == -1) {
+ return;
+ }
+
+ $ago = $diffdays * Date_Calc::compareDates(date('j', $timestamp),
date('n', $timestamp), date('Y', $timestamp),
+ date('j'), date('n'), date('Y'));
+
+ if ($ago < -1) {
+ return sprintf(_(" (%s days ago)"), $diffdays);
+ } elseif ($ago == -1) {
+ return _(" (yesterday)");
+ } elseif ($ago == 0) {
return _(" (today)");
} elseif ($ago == 1) {
- return _(" (yesterday)");
+ return _(" (tomorrow)");
} else {
- return sprintf(_(" (%s days ago)"), $ago);
+ return sprintf(_(" (in %s days )"), $diffdays);
}
}
Quoting "Jason M. Felice" <jfelice at cronosys.com>:
> Jens A. Tkotz wrote:
>
>> Hello,
>>
>> i use horde/hermes HEAD.
>>
>> i use hermes to manage the time i spend a work.
>> the next 3 day are holidays, but i entered them.
>>
>> i got:
>>
>> ... 3. Jan 2005 (yesterday) ...
>> ... 4. Jan 2005 (today) ...
>> ... 5. Jan 2005 (yesterday) ...
>> ... 6. Jan 2005 (2 days ago) ...
>> ... 7. Jan 2005 (3 days ago) ...
>>
>>
>> As you can see, the dates in the future are marked wrong.
>>
> I'm grateful for the report. Would you be willing to report this on
> bugs.horde.org? (Or submit a patch <g>)
>
> -- Jason M. Felice
> Cronosys, LLC <http://www.cronosys.com/>
> 216.221.4600 x302
>
> -- hermes mailing list - Join the hunt: http://horde.org/bounties/#hermes
> Frequently Asked Questions: http://horde.org/faq/
> To unsubscribe, mail: hermes-unsubscribe at lists.horde.org
>
--
_________________________
Ich sag mal .... Charisma
More information about the hermes
mailing list