[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    Re: default short date format
From:       Stefan Taferner <taferner () salzburg ! co ! at>
Date:       2000-04-06 6:35:33
[Download RAW message or body]

On Thu, 06 Apr 2000, Don Sanders wrote:
> I agree this sounds like an improvement.
>
> I reverted a change to KMail in CVS that made it use the localization stuff
> because the format used was very confusing.
>
> Currently KMail uses a format like:
> Thu, 06 Apr 2000
>
> Hmm, any chance of getting the "Thu, " included this would definitely mean
> I would use localisation stuff.

If you are talking of the date field in the message list: I have a code
snipplet for you (from kmail2). I don't have time to add it currently, but
it works.

This code returns a string that contains the date relative to the current 
date. Within 24 hours only the hour is returned, then only the weekday,
then only the date, etc.

Maybe usable?

Kind regards,
Stefan

----------------------------------------------
const QCString KMIndexRec::dateStr(const time_t& mDate) const
{
    QCString result;
    time_t diff, t, now, midnight;
    struct tm* tm;
    char* fmt;
    int nowHour;
 
    t = localDate();
    now = time(0);
 
    tm = localtime(&now);
    nowHour = tm->tm_hour;
    tm->tm_hour = 0;
    tm->tm_min  = 0;
    tm->tm_sec  = 0;
    midnight = mktime(tm);
 
    diff = now - t;
 
    if (diff >= -4*3600 &&
        ((nowHour >= 12 && t-midnight > 0) ||
         (nowHour < 12 && t > midnight-6*3600)))
    {
      fmt = "%X";
    }
    else if (diff >= 0 && diff < 3600*24*7)
    {
      fmt = "%A";
    }
    else fmt = "%d %b %Y";
 
    strftime(result.data(), 64, fmt, localtime(&t));
    result[63] = '\0';
 
    return result;
}                                                                             

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic