Bug 340260 - Kmail composer's template ODATE/ODATESHORT renders incorrect dates.
Summary: Kmail composer's template ODATE/ODATESHORT renders incorrect dates.
Status: RESOLVED NOT A BUG
Alias: None
Product: kmail2
Classification: Applications
Component: composer (show other bugs)
Version: 4.14.1
Platform: Gentoo Packages Linux
: NOR normal
Target Milestone: ---
Assignee: kdepim bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-10-23 15:17 UTC by Cezary Statkiewicz
Modified: 2015-08-12 11:43 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Cezary Statkiewicz 2014-10-23 15:17:30 UTC
Hi,

 I've noticed that %ODATE and %ODATESHORT will render incorrect results:

For example, email's header:

Date: Thu, 23 Oct 2014 15:05:17 +0000

Will be translated to (with `On %ODATE %ODATESHORT %OTIMELONG %OTIME %OFROMNAME wrote' template):

On Thursday 10 October 2014 10/10/2014 15:05:17 15:05 bugzilla_noreply@kde.org wrote:

Other examples (no other Date headers were available):

Date: Wed, 22 Oct 2014 07:58:41 -0700
On Wednesday 09 October 2014 09/10/2014 07:58:41 07:58 XXX wrote:

Date: Tue, 21 Oct 2014 11:51:09 -0700
On Tuesday 08 October 2014 08/10/2014 11:51:09 11:51 XXX wrote:

Date: Mon, 20 Oct 2014 22:02:06 +0000
On Monday 07 October 2014 07/10/2014 22:02:06 22:02 XXX wrote:

Reproducible: Always
Comment 1 Laurent Montel 2014-10-23 17:20:47 UTC
Hi,
Could you provide actual value and expected value please.
Comment 2 Cezary Statkiewicz 2014-10-23 17:36:03 UTC
Here are few samples from my inbox. Let me know if you need more or on specific dates:

----
 Original message's Date header:
    Date: Wed, 22 Oct 2014 07:58:41 -0700

 Value rendered from response template:
    On Wednesday 09 October 2014 09/10/2014 07:58:41 07:58 XXX wrote:

 Expected Value that should be rendered
    On Wednesday 22 October 2014 22/10/2014 07:58:41 07:58 XXX wrote:
----
---
 Original message's Date header:
   Date: Tue, 21 Oct 2014 11:51:09 -0700

 Value rendered from response template:
   On Tuesday 08 October 2014 08/10/2014 11:51:09 11:51 XXX wrote:

 Expected Value that should be rendered
   On Tuesday 21 October 2014 21/10/2014 11:51:09 11:51 XXX wrote:
---
---
 Original message's Date header:
   Date: Mon, 20 Oct 2014 22:02:06 +0000

 Value rendered from response template:
   On Monday 07 October 2014 07/10/2014 22:02:06 22:02 XXX wrote:

 Expected Value that should be rendered
   On Monday 20 October 2014 20/10/2014 22:02:06 22:02 XXX wrote:
---
---
 Original message's Date header:
   Date: Wed, 1 Oct 2014 07:58:34 +0000

 Value rendered from response template:
   On Wednesday 18 September 2014 18/09/2014 07:58:34 07:58 XXX wrote:

 Expected Value that should be rendered
  On Wednesday 1 October 2014 01/10/2014 07:58:34 07:58 XXX wrote:
---
---
 Original message's Date header:
  Date: Mon, 22 Sep 2014 01:51:28 +0200

 Value rendered from response template:
  On Monday 09 September 2014 09/09/2014 01:51:28 01:51 XXX wrote:

 Expected Value that should be rendered
  On Monday 22 September 2014 22/09/2014 01:51:28 01:51 XXX wrote:
---
Comment 3 Laurent Montel 2014-10-24 09:08:09 UTC
Please paste or attach an exact message here please.

Because ODATE == original date
see code:
"
            } else if ( cmd.startsWith( QLatin1String( "ODATE" ) ) ) {
                kDebug() << "Command: ODATE";
                i += strlen( "ODATE" );
                if ( mOrigMsg ) {
                    const QDateTime date = mOrigMsg->date()->dateTime().dateTime();
                    const QString str = KGlobal::locale()->formatDate( date.date(), KLocale::LongDate );
                    plainBody.append( str );
                    const QString body = plainToHtml( str );
                    htmlBody.append( body );
                }
"
=> it will take date from original message.

So I need to have a exact message for testing it.
For me code is ok.

I don't understand how it can take another date.
Template uses currentDate => %DATE or original date %ODATE

Regards
Comment 4 Cezary Statkiewicz 2014-10-24 09:38:44 UTC
I've attached original date in samples already. Here's your last comment:
----
Return-Path: <bugzilla_noreply@kde.org>
Delivered-To: cezio@thelirium.net
Received: from bugs.kde.org (bugs.kde.org [5.9.99.188])
	(using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits))
	(No client certificate requested)
	by ks388619.kimsufi.com (Postfix) with ESMTPS id 64641801F6
	for <cezio@thelirium.net>; Fri, 24 Oct 2014 11:09:04 +0200 (CEST)
Received: from www-data by bugs.kde.org with local (Exim 4.82)
	(envelope-from <bugzilla_noreply@kde.org>)
	id 1Xhaqw-0003O3-0E
	for cezio@thelirium.net; Fri, 24 Oct 2014 09:08:10 +0000
From: Laurent Montel <montel@kde.org>
Sender: bugzilla_noreply@kde.org
To: cezio@thelirium.net
Subject: [kmail2] [Bug 340260] Kmail composer's template ODATE/ODATESHORT
 renders incorrect dates.
Date: Fri, 24 Oct 2014 09:08:09 +0000
Reply-To: bug-control@bugs.kde.org
X-Bugzilla-Reason: Reporter
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: kmail2
X-Bugzilla-Component: composer
X-Bugzilla-Version: 4.14.1
X-Bugzilla-Keywords: 
X-Bugzilla-Severity: normal
X-Bugzilla-Who: montel@kde.org
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Priority: NOR
X-Bugzilla-Assigned-To: kdepim-bugs@kde.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: 
Message-ID: <bug-340260-188988-w2HmLaB60R@http.bugs.kde.org/>
In-Reply-To: <bug-340260-188988@http.bugs.kde.org/>
References: <bug-340260-188988@http.bugs.kde.org/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://bugs.kde.org/
Auto-Submitted: auto-generated
MIME-Version: 1.0

https://bugs.kde.org/show_bug.cgi?id=340260

--- Comment #3 from Laurent Montel <montel@kde.org> ---
Please paste or attach an exact message here please.

Because ODATE == original date
see code:
"
            } else if ( cmd.startsWith( QLatin1String( "ODATE" ) ) ) {
                kDebug() << "Command: ODATE";
                i += strlen( "ODATE" );
                if ( mOrigMsg ) {
                    const QDateTime date =
mOrigMsg->date()->dateTime().dateTime();
                    const QString str = KGlobal::locale()->formatDate(
date.date(), KLocale::LongDate );
                    plainBody.append( str );
                    const QString body = plainToHtml( str );
                    htmlBody.append( body );
                }
"
=> it will take date from original message.

So I need to have a exact message for testing it.
For me code is ok.

I don't understand how it can take another date.
Template uses currentDate => %DATE or original date %ODATE

Regards

-- 
You are receiving this mail because:
You reported the bug.

---

And here's rendered response beginning:

---
On Friday 11 October 2014 11/10/2014 09:08:09 09:08 Laurent Montel wrote:
> https://bugs.kde.org/show_bug.cgi?id=340260
> 
> --- Comment #3 from Laurent Montel <montel@kde.org> ---
> Please paste or attach an exact message here please.
> 
----

As you probably noticed, Date rendered is incorrect. Should be 24th Oct, and it's 11th Oct. 

Here's also my template:

----
%REM="Default reply all template"%-
On %ODATE %ODATESHORT %OTIMELONG %OTIME %OFROMNAME wrote:
%QUOTE
%CURSOR
----

> I don't understand how it can take another date.
> Template uses currentDate => %DATE or original date %ODATE

Maybe date is parsed incorrectly? But from the other hand, Message date is displayed correctly in message list and in message view. Also, date skew seems to be constant, 13 days.
Comment 5 Cezary Statkiewicz 2015-08-10 15:06:46 UTC
Ok, I've finally nailed the problem. Constant two weeks difference should give a clue much earlier, but I've followed old, good rule: "if it doesn't work, blame others!".

It turned out that I had Julian calendar set somehow, instead of Gregorian.

Sorry for the fuss. I think this can be closed.
Comment 6 Allen Winter 2015-08-12 11:43:42 UTC
thanks for notifying us.