Author Topic: annotations enhancement: customized creation/modified dates  (Read 9615 times)

hs2

  • Senior Community Member
  • Posts: 2761
  • Hero Points: 292
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
Code: [Select]
// 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)
Code: [Select]
// 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
« Last Edit: July 06, 2007, 10:25:17 AM by hs2 »

at5dapa1

  • Senior Community Member
  • Posts: 282
  • Hero Points: 24
Re: annotations enhancement: customized creation/modified dates
« Reply #1 on: July 12, 2007, 06:29:42 AM »
Yes, is much better! Instead mm/dd/yyyy it uses now yyyy/mm/dd. Thanks!
I like better getcdate( '/', true, true).   :)

hs2

  • Senior Community Member
  • Posts: 2761
  • Hero Points: 292
Re: annotations enhancement: customized creation/modified dates
« Reply #2 on: August 03, 2007, 11:24:37 PM »
@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

at5dapa1

  • Senior Community Member
  • Posts: 282
  • Hero Points: 24
Re: annotations enhancement: customized creation/modified dates
« Reply #3 on: August 12, 2007, 06:10:33 PM »
Sorry for late answer!
Thank you very much for pointing about the update! Quite many fixes there! :)

hs2

  • Senior Community Member
  • Posts: 2761
  • Hero Points: 292
Re: annotations enhancement: customized creation/modified dates
« Reply #4 on: August 24, 2007, 11:23:18 PM »
@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.

at5dapa1

  • Senior Community Member
  • Posts: 282
  • Hero Points: 24
Re: annotations enhancement: customized creation/modified dates
« Reply #5 on: August 25, 2007, 05:02:11 PM »
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