From 03929dac2a29664878d2c971648a4fe1fb698462 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 15 Apr 2024 22:19:02 +0200 Subject: Adding upstream version 20231031. Signed-off-by: Daniel Baumann --- scripts/itime.pl | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 scripts/itime.pl (limited to 'scripts/itime.pl') 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); -- cgit v1.2.3