[Tkabber-dev] r1813 - in trunk/tkabber: . plugins/iq

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Fri Jul 17 15:30:16 MSD 2009


Author: sergei
Date: 2009-07-17 15:30:16 +0400 (Fri, 17 Jul 2009)
New Revision: 1813

Modified:
   trunk/tkabber/ChangeLog
   trunk/tkabber/plugins/iq/time2.tcl
Log:
	* plugins/iq/time2.tcl: Fixed timezone definition (and made it fail to
	  work with Tcl 8.4 or older on MS Windows systems).


Modified: trunk/tkabber/ChangeLog
===================================================================
--- trunk/tkabber/ChangeLog	2009-06-21 10:19:30 UTC (rev 1812)
+++ trunk/tkabber/ChangeLog	2009-07-17 11:30:16 UTC (rev 1813)
@@ -1,3 +1,8 @@
+2009-07-17  Sergei Golovan  <sgolovan at nes.ru>
+
+	* plugins/iq/time2.tcl: Fixed timezone definition (and made it fail to
+	  work with Tcl 8.4 or older on MS Windows systems).
+
 2009-06-21  Sergei Golovan  <sgolovan at nes.ru>
 
 	* messages.tcl: Minor fixes in widgets packing (entry fields shouldn't

Modified: trunk/tkabber/plugins/iq/time2.tcl
===================================================================
--- trunk/tkabber/plugins/iq/time2.tcl	2009-06-21 10:19:30 UTC (rev 1812)
+++ trunk/tkabber/plugins/iq/time2.tcl	2009-07-17 11:30:16 UTC (rev 1813)
@@ -18,7 +18,7 @@
 		    -cdata [clock format $curtime \
 				  -format "%Y-%m-%dT%TZ" -gmt true]] \
 	      [::xmpp::xml::create tzo \
-		    -cdata [timezone_offset]]]
+		    -cdata [timezone_offset $curtime]]]
     
     set res [::xmpp::xml::create time \
 		    -xmlns urn:xmpp:time \
@@ -27,18 +27,13 @@
     return [list result $res]
 }
 
-proc timezone_offset {} {
-    set H [clock format 0 -format %H]
-    set M [clock format 0 -format %M]
-    set S +
+proc timezone_offset {curtime} {
+    # Doesn't work with Tcl 8.4 on MS Windows
+    set tz [clock format $curtime -format %z]
+    regsub {[+-]0000} $tz {Z} tz1
+    regsub {(\d\d)(\d\d)} $tz1 {\1:\2} tz2
 
-    if {$H > 12} {
-	set H [expr {24 - $H}]
-	set M [expr {60 - $M}]
-	set S -
-    }
-
-    return $S$H:$M
+    return $tz2
 }
 
 ::xmpp::iq::register get time urn:xmpp:time [namespace current]::xmpp_time



More information about the Tkabber-dev mailing list