]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - data/rbot/plugins/time.rb
markov: refactor triplet learning
[user/henk/code/ruby/rbot.git] / data / rbot / plugins / time.rb
index 9f8b8d7cb05bbd045d40314a843882f7b5517df7..190abd6acdcde59f4f645f8300c452f2f8d5b5de 100644 (file)
@@ -1,6 +1,11 @@
-# Time Zone Plugin for rbot
-# (c) 2006 Ian Monroe <ian@monroe.nu>
-# Licensed under MIT License.
+#-- vim:sw=2:et
+#++
+#
+# :title: Time Zone Plugin for rbot
+#
+# Author:: Ian Monroe <ian@monroe.nu>
+# Copyright:: (C) 2006 Ian Monroe
+# License:: MIT license
 
 require 'tzinfo'
 
@@ -40,25 +45,26 @@ class TimePlugin < Plugin
     end
     ['/', '_'].each { |sp|
         arr = Array.new
-        zone.split(sp).each{ |s| 
+        zone.split(sp).each{ |s|
             s[0] = s[0,1].upcase
             s[1, s.length] = s[1, s.length].downcase if sp == '/'
             arr.push(s) }
             zone = arr.join( sp )
         }
-    
-    TZInfo::Timezone.get( zone ).now
+
+    tz = TZInfo::Timezone.get( zone )
+    "#{tz.friendly_identifier} - #{tz.now.strftime( '%a %b %d %H:%M' )} #{tz.current_period.abbreviation}"
   end
 
   def showTime(m, params)
     zone = params[:where].join('_')
     if params[:where].size > 0 then
       begin
-        m.reply "#{zone} - #{getTime( m,  zone )}"
+        m.reply getTime( m,  zone )
       rescue TZInfo::InvalidTimezoneIdentifier
         if @registry.has_key?( zone ) then
           zone =  @registry[ zone ]
-          m.reply "#{zone} - #{getTime( m,  zone )}"
+          m.reply getTime( m,  zone )
         else
           m.reply "#{zone} is an unknown time."
         end
@@ -66,7 +72,7 @@ class TimePlugin < Plugin
     else
       if @registry.has_key?( m.sourcenick) then
         zone = @registry[ m.sourcenick ]
-        m.reply "#{m.sourcenick}: #{zone} - #{getTime( m,  zone )}"
+        m.reply "#{m.sourcenick}: #{getTime( m,  zone )}"
       else
         m.reply "#{m.sourcenick}: use time set <Continent/City> to set your timezone."
       end