diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 20:19:02 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 20:19:02 +0000 |
commit | 03929dac2a29664878d2c971648a4fe1fb698462 (patch) | |
tree | 02c5e2b3e006234aa29545f7a93a1ce01b291a8b /scripts/itime.pl | |
parent | Initial commit. (diff) | |
download | irssi-scripts-03929dac2a29664878d2c971648a4fe1fb698462.tar.xz irssi-scripts-03929dac2a29664878d2c971648a4fe1fb698462.zip |
Adding upstream version 20231031.upstream/20231031upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | scripts/itime.pl | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/scripts/itime.pl b/scripts/itime.pl new file mode 100644 index 0000000..8483a59 --- /dev/null +++ b/scripts/itime.pl @@ -0,0 +1,47 @@ +# Internet Time statusbar item. +# See http://www.timeanddate.com/time/internettime.html + +# /STATUSBAR window ADD itime + +use strict; +use Irssi::TextUI; + +use vars qw($VERSION %IRSSI $itime_ratio $current_itime); + +$VERSION = '0.9'; +%IRSSI = ( + authors => 'Johan "Ion" Kiviniemi', + contact => 'ion at hassers.org', + name => 'itime', + description => +'Internet Time statusbar item. See http://www.timeanddate.com/time/internettime.html', + sbitems => 'itime', + license => 'Public Domain', + url => 'http://ion.amigafin.org/scripts/', + changed => 'Tue Mar 12 22:20 EET 2002', +); + +$itime_ratio = 1000 / 86400; +$current_itime = get_itime(); + +sub get_itime { + my ($s, $m, $h) = gmtime time + 3600; + my $itime = $itime_ratio * (3600 * $h + 60 * $m + $s); + return sprintf '@%03d', int $itime; +} + +sub itime { + my ($item, $get_size_only) = @_; + $item->default_handler($get_size_only, undef, $current_itime, 1); +} + +sub refresh_itime { + my $itime = get_itime(); + return if $itime eq $current_itime; + $current_itime = $itime; + Irssi::statusbar_items_redraw('itime'); +} + +Irssi::statusbar_item_register('itime', '{sb $0}', 'itime'); +Irssi::statusbars_recreate_items(); +Irssi::timeout_add(5000, 'refresh_itime', undef); |