Adds TIMEAGO header field. From: Ben Clifford --- pine/mailindx.c | 43 +++++++++++++++++++++++++++++++++++++++++++ pine/pine.h | 3 ++- 2 files changed, 45 insertions(+), 1 deletions(-) diff --git a/pine/mailindx.c b/pine/mailindx.c index f250b4f..3c93a98 100644 --- a/pine/mailindx.c +++ b/pine/mailindx.c @@ -773,6 +773,9 @@ index_lister(state, cntxt, folder, strea * then when the day changes the date column will change. All of the * Today's will become Yesterday's at midnight. So we have to * clear the cache at midnight. + * BENC: this is possibly going to be a problem with + * TIMEAGO as that will change every minute for some stuff. + * oook. */ if(format_includes_smartdate()){ char db[200]; @@ -2977,6 +2980,7 @@ INDEX_COL_S **answer; case iMonAbb: case iInit: case iDayOfWeekAbb: + case iTimeAgo: (*answer)[column].req_width = 3; break; case iYear: @@ -3119,6 +3123,7 @@ static INDEX_PARSE_T itokens[] = { {"LASTYEAR2DIGIT", iLstYear2Digit, FOR_REPLY_INTRO|FOR_TEMPLATE|FOR_FILT}, {"ARROW", iArrow, FOR_INDEX}, {"CURSORPOS", iCursorPos, FOR_TEMPLATE}, + {"TIMEAGO", iTimeAgo, FOR_INDEX}, {NULL, iNothing, FOR_NOTHING} }; @@ -4858,6 +4863,7 @@ format_index_index_line(idata) case iMonLong: case iDayOfWeekAbb: case iDayOfWeek: + case iTimeAgo: date_str(fetch_date(idata), cdesc->ctype, 0, str); break; @@ -6814,6 +6820,43 @@ date_str(datesrc, type, v, str) } break; + + case iTimeAgo: + /* + * need number and name of units. + */ + { + long minutes_ago = 0; + + int units=99; + char spec='X'; + + struct date now; + char dbuf[200]; + + rfc822_date(dbuf); + parse_date(dbuf, &now); + + /* compute how many seconds ago */ + + minutes_ago += 60*24*365* (now.year - d.year); + minutes_ago += 60*24* (day_of_year(&now) - day_of_year(&d)); + minutes_ago += 60* (now.hour - d.hour); + minutes_ago += (now.minute - d.minute); + + minutes_ago += 60*(d.hours_off_gmt - now.hours_off_gmt); + minutes_ago += d.min_off_gmt - now.min_off_gmt; + + if(minutes_ago < 0) { units=0; spec='F'; } else + if(minutes_ago < 60) { units = minutes_ago; spec='m'; } else + if(minutes_ago < 60*24) { units = minutes_ago/60; spec='h'; } else + if(minutes_ago < 60*24*99) { units = minutes_ago/60/24; spec='d'; } else + if(minutes_ago < 60*24*365) { units = minutes_ago/60/24/365; spec='y'; } else + {units = 98; spec='X'; } + + sprintf(str,"%2d%c",units,spec); + } + break; } if(type == iSTime || diff --git a/pine/pine.h b/pine/pine.h index 9c5a58b..7d32d63 100644 --- a/pine/pine.h +++ b/pine/pine.h @@ -2613,7 +2613,8 @@ typedef enum {iNothing, iStatus, iFStatu iSTime, iKSize, iRoleNick, iScore, iDayOfWeekAbb, iDayOfWeek, - iDay, iDayOrdinal, iMonAbb, iMonLong, iMon, iYear} IndexColType; + iDay, iDayOrdinal, iMonAbb, iMonLong, iMon, iYear, + iTimeAgo} IndexColType; typedef enum {AllAuto, Fixed, Percent, WeCalculate, Special} WidthType; typedef enum {Left, Right} ColAdj;