From f92453c4bffec2e4fd291102d53acb4adb810676 Mon Sep 17 00:00:00 2001 From: Tom Feist Date: Sun, 25 Sep 2011 00:40:16 +0100 Subject: added any_time.pl adds a statusbar item called 'any_time' with a custom time format configuration (with /set any_time_format %H:%M or whatever. Uses standard POSIX strftime formats). --- feature-tests/any_time.pl | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 feature-tests/any_time.pl (limited to 'feature-tests') diff --git a/feature-tests/any_time.pl b/feature-tests/any_time.pl new file mode 100644 index 0000000..fd00b02 --- /dev/null +++ b/feature-tests/any_time.pl @@ -0,0 +1,37 @@ + +use strict; +use warnings; + +use Irssi; +use Irssi::TextUI; # for sbar_items_redraw +use POSIX qw/strftime/; + +my $time_format; + +sub any_time_sb { + my ($sb_item, $get_size_only) = @_; + + my @time_now = localtime(); + my $formatted_time = strftime($time_format, @time_now); + + $sb_item->default_handler($get_size_only, "{sb $formatted_time}", '', 0); +} + +sub sig_setup_changed { + $time_format = Irssi::settings_get_str('any_time_format'); +} + +sub init { + Irssi::settings_add_str('any_time', 'any_time_format', '%H:%M'); + Irssi::signal_add('setup changed', \&sig_setup_changed); + + sig_setup_changed(); + + Irssi::signal_add('expando timer', + sub { Irssi::statusbar_items_redraw('any_time') }); + + + Irssi::statusbar_item_register ('any_time', 0, 'any_time_sb'); +} + +init(); -- cgit v1.2.3