Hi,
I've made an enhancement to the cool annotations feature (SE v12.02) which allows customized creation/modified date entries.
Currently the format is fixed to e.g. '7/6/2007 11:31am' which doesn't support proper sorting.
The patch consists of 2 parts:
1. modified 'annotations.e' which now uses a 'annotation_date' fct. instead of hardwired '_date() " " _time()' to get date-time strings
// global function or command name returning the properly formatted 'date - time' string
_str def_annotation_date_hook = '';
static _str annotation_date ()
{
if ( def_annotation_date_hook != '' )
{
int index = find_index(def_annotation_date_hook,PROC_TYPE|COMMAND_TYPE);
if (index) return call_index(index);
}
return _date()" "_time();
}
This function retrieves an fct./command name contained in 'def_annotation_date_hook'. If set this callback is used instead of the default method.
2. the callback implementation (just load 'annotation_date_hook.e' or add to e.g. 'vusrmacs.e' or your personal macro toolbox)
// date string formatting helper
static _str getcdate ( _str delim = '/', boolean yyyy = true, boolean lzero = false )
{
_str month, day, year;
parse _date() with month'/'day'/'year;
if (lzero && length(month)<2) month='0'month;
if (lzero && length(day)<2) day='0'day;
if (length(year)>2 && !yyyy) year=substr(year,3);
return ( year delim month delim day );
}
// used in annotations.e for (textual) creation/modifed date fields
// enable hook: set-var def_annotation_date_hook annotation_date_hook
// disable (use default): set-var def_annotation_date_hook <empty string>
_str annotation_date_hook ()
{
// e.g. '2007/7/6 11:31' or '2007/7/6 23:31'
return getcdate( '/', true, false)" "substr ( _time( 'M'), 1, 5 );
}
Have fun,
HS2