SlickEdit Community
SlickEdit Product Discussion => SlickEditĀ® => Slick-CĀ® Macro Programming => Topic started by: hs2 on July 06, 2007, 10:23:35 AM
-
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
-
Yes, is much better! Instead mm/dd/yyyy it uses now yyyy/mm/dd. Thanks!
I like better getcdate( '/', true, true). :)
-
@at5dapa1: Updated annotations.e incl. the latest hotfix http://community.slickedit.com/index.php?topic=1874.msg8128#msg8128
Unfortunately the official version still doesn't support a date time formatting callback - but I don't really expect that ;)
HS2
-
Sorry for late answer!
Thank you very much for pointing about the update! Quite many fixes there! :)
-
@at5dapa1: The usual update for v12.03 ...
HS2
PS: Please tell me if you don't need it any longer. I'm maintaing it anyway until the binary (UTC) timestamps are implemented.
-
Thanks HS2 for the good news! So they released 12.0.3! Really good news! :)
I'll update for myself the "customized creation/modified date entries" from annotations.e. It would be nice if will be included sometime into the final product, but I think this is why we love so much this tool: if we want something, then we can just do it ourselves! Right? ;)
Thanks again for the great support you are giving into these forums! And hope you'll be able to keep your good habit as long as possible!
Daniel