Changeset 0b2afba


Ignore:
Timestamp:
Sep 3, 2009, 11:27:00 PM (12 years ago)
Author:
Alex Dehnert <adehnert@mit.edu>
Branches:
master, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
d694c55
Parents:
4df918b
git-author:
Alex Dehnert <adehnert@mit.edu> (09/03/09 17:02:49)
git-committer:
Alex Dehnert <adehnert@mit.edu> (09/03/09 23:27:00)
Message:
Add configurable time display

Includes :showdate, :hidedate, and :timeformat
commands to change the time display and
redisplay messages.
Location:
perl/lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • perl/lib/BarnOwl.pm

    r4df918b r0b2afba  
    327327
    328328sub register_builtin_commands {
     329    # Filter modification
    329330    BarnOwl::new_command("filterappend",
    330331                         sub { filter_append_helper('appending', '', @_); },
     
    346347                           summary => "append 'or <text>' to filter",
    347348                           usage => "filteror <filter> <text>",
     349                       });
     350
     351    # Date formatting
     352    BarnOwl::new_command("showdate",
     353                         sub { BarnOwl::time_format('showdate', '%Y-%m-%d %H:%M'); },
     354                       {
     355                           summary => "Show date in timestamps for supporting styles.",
     356                           usage => "showdate",
     357                       });
     358
     359    BarnOwl::new_command("hidedate",
     360                         sub { BarnOwl::time_format('hidedate', '%H:%M'); },
     361                       {
     362                           summary => "Don't show date in timestamps for supporting styles.",
     363                           usage => "hidedate",
     364                       });
     365
     366    BarnOwl::new_command("timeformat",
     367                         \&BarnOwl::time_format,
     368                       {
     369                           summary => "Set the format for timestamps and re-display messages",
     370                           usage => "timeformat <format>",
    348371                       });
    349372
     
    379402                             summary => 'Show modifications to filters by filterappend and friends.'});
    380403
     404=head3 time_format FORMAT
     405
     406Set the format for displaying times (variable timeformat) and redisplay
     407messages.
     408
     409=cut
     410
     411my $timeformat;
     412
     413sub time_format
     414{
     415    my $function = shift;
     416    my $format = shift;
     417    if(!$format)
     418    {
     419        return $timeformat;
     420    }
     421    if(shift)
     422    {
     423        return "Wrong number of arguments for command";
     424    }
     425    $timeformat = $format;
     426    redisplay();
     427}
     428
    3814291;
  • perl/lib/BarnOwl/Style/Default.pm

    r5550eb0 r0b2afba  
    4242    my $self = shift;
    4343    my $m = shift;
    44     return strftime('%H:%M', localtime($m->unix_time));
     44    my $dateformat = BarnOwl::time_format('get_time_format');
     45    return strftime($dateformat, localtime($m->unix_time));
    4546}
    4647
Note: See TracChangeset for help on using the changeset viewer.