diff options
| author | Alexander Færøy | 2014-05-31 13:10:46 +0200 | 
|---|---|---|
| committer | Alexander Færøy | 2014-05-31 13:10:46 +0200 | 
| commit | 2d0759e6ca5767b48bcc85bf38c2c43d5f0b63b1 (patch) | |
| tree | 1c5e6d817c88e67b46e216a50e0aef5428bf63df /scripts/itime.pl | |
| parent | 2d080422d79d1fd49d6c5528593ccaaff9bfc583 (diff) | |
| download | scripts.irssi.org-2d0759e6ca5767b48bcc85bf38c2c43d5f0b63b1.tar.bz2 | |
Import scripts from scripts.irssi.org
Diffstat (limited to 'scripts/itime.pl')
| -rw-r--r-- | scripts/itime.pl | 46 | 
1 files changed, 46 insertions, 0 deletions
| diff --git a/scripts/itime.pl b/scripts/itime.pl new file mode 100644 index 0000000..3f63f8c --- /dev/null +++ b/scripts/itime.pl @@ -0,0 +1,46 @@ +# 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', +    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); | 
